Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneHezser committed Nov 1, 2024
1 parent 0b8e27f commit 8621959
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions avm/ptn/deployment-script/import-image-to-acr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ The password for the source registry. Required if the source registry is private
- Required: No
- Type: securestring
- Default: `''`
- Example: `keyVault.getSecret("keyVaultSecretName")`

### Parameter: `sourceRegistryUsername`

Expand Down
4 changes: 3 additions & 1 deletion avm/ptn/deployment-script/import-image-to-acr/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ param sourceRegistryUsername string = ''

@description('Optional. The password for the source registry. Required if the source registry is private, or to logon to the public docker registry.')
@secure()
@metadata({ example: 'keyVault.getSecret("keyVaultSecretName")' })
param sourceRegistryPassword string = ''

@description('Optional. The new image name in the ACR. You can use this to import a publically available image with a custom name for later updating from e.g., your build pipeline.')
Expand Down Expand Up @@ -167,7 +168,8 @@ module imageImport 'br/public:avm/res/resources/deployment-script:0.4.0' = {
location: location
tags: tags
managedIdentities: useExistingManagedIdentity
? managedIdentities
// ? managedIdentities // once the referenced module is using the common type
? { userAssignedResourcesIds: managedIdentities.userAssignedResourceIds! }
: { userAssignedResourcesIds: [newManagedIdentity.id] }
kind: 'AzureCLI'
runOnce: runOnce
Expand Down
11 changes: 6 additions & 5 deletions avm/ptn/deployment-script/import-image-to-acr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.30.23.60470",
"templateHash": "13212154582752939638"
"templateHash": "17604113955002769079"
},
"name": "import-image-to-acr",
"description": "This modules deployes an image to an Azure Container Registry.",
Expand Down Expand Up @@ -129,6 +129,7 @@
"type": "securestring",
"defaultValue": "",
"metadata": {
"example": "keyVault.getSecret(\"keyVaultSecretName\")",
"description": "Optional. The password for the source registry. Required if the source registry is private, or to logon to the public docker registry."
}
},
Expand Down Expand Up @@ -194,7 +195,7 @@
"type": "object",
"nullable": true,
"metadata": {
"example": " {\n \"key1\": \"value1\"\n \"key2\": \"value2\"\n }\n ",
"example": " {\r\n \"key1\": \"value1\"\r\n \"key2\": \"value2\"\r\n }\r\n ",
"description": "Optional. Tags of the resource."
}
}
Expand Down Expand Up @@ -306,7 +307,7 @@
"tags": {
"value": "[parameters('tags')]"
},
"managedIdentities": "[if(variables('useExistingManagedIdentity'), createObject('value', parameters('managedIdentities')), createObject('value', createObject('userAssignedResourcesIds', createArray(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', coalesce(parameters('managedIdentityName'), 'id-ContainerRegistryImport'))))))]",
"managedIdentities": "[if(variables('useExistingManagedIdentity'), createObject('value', createObject('userAssignedResourcesIds', parameters('managedIdentities').userAssignedResourceIds)), createObject('value', createObject('userAssignedResourcesIds', createArray(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', coalesce(parameters('managedIdentityName'), 'id-ContainerRegistryImport'))))))]",
"kind": {
"value": "AzureCLI"
},
Expand Down Expand Up @@ -375,7 +376,7 @@
"value": "[parameters('subnetResourceIds')]"
},
"scriptContent": {
"value": "#!/bin/bash\n echo \"Waiting on RBAC replication ($initialDelay)\\n\"\n sleep $initialDelay\n\n # retry loop to catch errors (usually RBAC delays, but 'Error copying blobs' is also not unheard of)\n retryLoopCount=0\n until [ $retryLoopCount -ge $retryMax ]\n do\n echo \"Importing Image ($retryLoopCount): $imageName into ACR: $acrName\\n\"\n if [ $overwriteExistingImage = 'true' ]; then\n if [ -n \"$sourceRegistryUsername\" ] && [ -n \"$sourceRegistryPassword\" ]; then\n az acr import -n $acrName --source $imageName --image $newImageName --force --username $sourceRegistryUsername --password $sourceRegistryPassword\n else\n az acr import -n $acrName --source $imageName --image $newImageName --force\n fi\n else\n if [ -n \"$sourceRegistryUsername\" ] && [ -n \"$sourceRegistryPassword\" ]; then\n az acr import -n $acrName --source $imageName --image $newImageName --username $sourceRegistryUsername --password $sourceRegistryPassword\n else\n az acr import -n $acrName --source $imageName --image $newImageName\n fi\n fi\n\n sleep $retrySleep\n retryLoopCount=$((retryLoopCount+1))\n done\n\n echo \"done\\n\""
"value": "#!/bin/bash\r\n echo \"Waiting on RBAC replication ($initialDelay)\\n\"\r\n sleep $initialDelay\r\n\r\n # retry loop to catch errors (usually RBAC delays, but 'Error copying blobs' is also not unheard of)\r\n retryLoopCount=0\r\n until [ $retryLoopCount -ge $retryMax ]\r\n do\r\n echo \"Importing Image ($retryLoopCount): $imageName into ACR: $acrName\\n\"\r\n if [ $overwriteExistingImage = 'true' ]; then\r\n if [ -n \"$sourceRegistryUsername\" ] && [ -n \"$sourceRegistryPassword\" ]; then\r\n az acr import -n $acrName --source $imageName --image $newImageName --force --username $sourceRegistryUsername --password $sourceRegistryPassword\r\n else\r\n az acr import -n $acrName --source $imageName --image $newImageName --force\r\n fi\r\n else\r\n if [ -n \"$sourceRegistryUsername\" ] && [ -n \"$sourceRegistryPassword\" ]; then\r\n az acr import -n $acrName --source $imageName --image $newImageName --username $sourceRegistryUsername --password $sourceRegistryPassword\r\n else\r\n az acr import -n $acrName --source $imageName --image $newImageName\r\n fi\r\n fi\r\n\r\n sleep $retrySleep\r\n retryLoopCount=$((retryLoopCount+1))\r\n done\r\n\r\n echo \"done\\n\""
}
},
"template": {
Expand Down Expand Up @@ -921,4 +922,4 @@
}
}
}
}
}

0 comments on commit 8621959

Please sign in to comment.