@@ -123,6 +123,7 @@ try {
123123 Write-Verbose - Verbose " Getting channel info"
124124 $channelJsonFileContent = Get-Content - Path $pathToChannelJson | ConvertFrom-Json
125125 $channel = $channelJsonFileContent.channel
126+ $whatIf = $channelJsonFileContent.whatIf
126127
127128 Write-Verbose - Verbose " Getting image info"
128129 $imgJsonFileContent = Get-Content - Path $pathToImgMetadataJson | ConvertFrom-Json
@@ -169,18 +170,38 @@ try {
169170 # Import (old) image by digest from MCR into our ACR
170171 $mcrImageNameDigest = " mcr.microsoft.com/powershell@$imageDigest "
171172 $acrEOLImageTag = " $tag -EOL"
172- az acr import -- name $env: DESTINATION_ACR_NAME -- source $mcrImageNameDigest -- image $acrEOLImageTag
173+ if (! $whatIf )
174+ {
175+ az acr import -- name $env: DESTINATION_ACR_NAME -- source $mcrImageNameDigest -- image $acrEOLImageTag
176+ }
177+ else {
178+ Write-Verbose - Verbose " az acr import --name $env: DESTINATION_ACR_NAME --source $mcrImageNameDigest --image $acrEOLImageTag "
179+ }
173180
174181 # Attach lifecycle annotation, which will eventually get synced to MCR
175182 $acrImageNameDigest = " $env: DESTINATION_ACR_NAME .azurecr.io/public/powershell@$imageDigest "
176- oras attach -- artifact- type " application/vnd.microsoft.artifact.lifecycle" -- annotation " vnd.microsoft.artifact.lifecycle.end-of-life.date=$endOfLifeDate " $acrImageNameDigest
183+ if (! $whatIf )
184+ {
185+ oras attach -- artifact- type " application/vnd.microsoft.artifact.lifecycle" -- annotation " vnd.microsoft.artifact.lifecycle.end-of-life.date=$endOfLifeDate " $acrImageNameDigest
186+ }
187+ else {
188+ Write-Verbose - Verbose " oras attach --artifact-type `" application/vnd.microsoft.artifact.lifecycle`" --annotation `" vnd.microsoft.artifact.lifecycle.end-of-life.date=$endOfLifeDate `" $acrImageNameDigest "
189+ }
190+
177191 }
178192
179193 # Need to push image for each tag
180194 $destination_image_full_name = " $env: DESTINATION_ACR_NAME .azurecr.io/public/powershell:${tag} "
181195 Write-Verbose - Verbose " dest img full name: $destination_image_full_name "
182196 Write-Verbose - Verbose " Pushing file $tarballFilePath to $destination_image_full_name "
183- ./ crane push $tarballFilePath $destination_image_full_name
197+ if (! $whatIf )
198+ {
199+ ./ crane push $tarballFilePath $destination_image_full_name
200+ }
201+ else {
202+ Write-Verbose " ./crane push $tarballFilePath $destination_image_full_name "
203+ }
204+
184205 Write-Verbose - Verbose " done pushing for tag: $tag "
185206 }
186207 }
0 commit comments