From 1412622a68539661d3715ba412a3efc265e8269b Mon Sep 17 00:00:00 2001 From: ChrisSidebotham-MSFT <48600046+ChrisSidebotham@users.noreply.github.com> Date: Wed, 6 Nov 2024 11:21:41 +0100 Subject: [PATCH] Fix for #3741 --- .../registry/cache-rule/main.bicep | 15 ++++++++++----- .../registry/cache-rule/main.json | 10 +++------- .../registry/credential-set/main.json | 4 ++-- avm/res/container-registry/registry/main.json | 10 +++------- .../registry/replication/main.json | 4 ++-- .../registry/scope-map/main.json | 4 ++-- .../registry/tests/e2e/cache/main.test.bicep | 7 ++++++- .../container-registry/registry/webhook/main.json | 4 ++-- 8 files changed, 30 insertions(+), 28 deletions(-) diff --git a/avm/res/container-registry/registry/cache-rule/main.bicep b/avm/res/container-registry/registry/cache-rule/main.bicep index 3a58558bc3..4935574bdf 100644 --- a/avm/res/container-registry/registry/cache-rule/main.bicep +++ b/avm/res/container-registry/registry/cache-rule/main.bicep @@ -24,11 +24,16 @@ resource registry 'Microsoft.ContainerRegistry/registries@2023-06-01-preview' ex resource cacheRule 'Microsoft.ContainerRegistry/registries/cacheRules@2023-06-01-preview' = { name: name parent: registry - properties: { - sourceRepository: sourceRepository - targetRepository: targetRepository - credentialSetResourceId: credentialSetResourceId - } + properties: !empty(credentialSetResourceId) + ? { + sourceRepository: sourceRepository + targetRepository: targetRepository + credentialSetResourceId: credentialSetResourceId + } + : { + sourceRepository: sourceRepository + targetRepository: targetRepository + } } @description('The Name of the Cache Rule.') diff --git a/avm/res/container-registry/registry/cache-rule/main.json b/avm/res/container-registry/registry/cache-rule/main.json index 4635d8cb66..7f92b7da69 100644 --- a/avm/res/container-registry/registry/cache-rule/main.json +++ b/avm/res/container-registry/registry/cache-rule/main.json @@ -4,8 +4,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.30.3.12046", - "templateHash": "17205938486061573561" + "version": "0.30.23.60470", + "templateHash": "6676256769294761512" }, "name": "Container Registries Cache", "description": "Cache for Azure Container Registry (Preview) feature allows users to cache container images in a private container registry. Cache for ACR, is a preview feature available in Basic, Standard, and Premium service tiers ([ref](https://learn.microsoft.com/en-us/azure/container-registry/tutorial-registry-cache)).", @@ -50,11 +50,7 @@ "type": "Microsoft.ContainerRegistry/registries/cacheRules", "apiVersion": "2023-06-01-preview", "name": "[format('{0}/{1}', parameters('registryName'), parameters('name'))]", - "properties": { - "sourceRepository": "[parameters('sourceRepository')]", - "targetRepository": "[parameters('targetRepository')]", - "credentialSetResourceId": "[parameters('credentialSetResourceId')]" - } + "properties": "[if(not(empty(parameters('credentialSetResourceId'))), createObject('sourceRepository', parameters('sourceRepository'), 'targetRepository', parameters('targetRepository'), 'credentialSetResourceId', parameters('credentialSetResourceId')), createObject('sourceRepository', parameters('sourceRepository'), 'targetRepository', parameters('targetRepository')))]" } ], "outputs": { diff --git a/avm/res/container-registry/registry/credential-set/main.json b/avm/res/container-registry/registry/credential-set/main.json index 1b1f243390..98215f9c8c 100644 --- a/avm/res/container-registry/registry/credential-set/main.json +++ b/avm/res/container-registry/registry/credential-set/main.json @@ -5,8 +5,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.30.3.12046", - "templateHash": "13281764602355848660" + "version": "0.30.23.60470", + "templateHash": "7759513970094711275" }, "name": "Container Registries Credential Sets", "description": "This module deploys an ACR Credential Set.", diff --git a/avm/res/container-registry/registry/main.json b/avm/res/container-registry/registry/main.json index 5e42d035ac..b560a86a4c 100644 --- a/avm/res/container-registry/registry/main.json +++ b/avm/res/container-registry/registry/main.json @@ -6,7 +6,7 @@ "_generator": { "name": "bicep", "version": "0.30.23.60470", - "templateHash": "2277340268999354626" + "templateHash": "14076061883339486537" }, "name": "Azure Container Registries (ACR)", "description": "This module deploys an Azure Container Registry (ACR).", @@ -1479,7 +1479,7 @@ "_generator": { "name": "bicep", "version": "0.30.23.60470", - "templateHash": "1396902957012921251" + "templateHash": "6676256769294761512" }, "name": "Container Registries Cache", "description": "Cache for Azure Container Registry (Preview) feature allows users to cache container images in a private container registry. Cache for ACR, is a preview feature available in Basic, Standard, and Premium service tiers ([ref](https://learn.microsoft.com/en-us/azure/container-registry/tutorial-registry-cache)).", @@ -1524,11 +1524,7 @@ "type": "Microsoft.ContainerRegistry/registries/cacheRules", "apiVersion": "2023-06-01-preview", "name": "[format('{0}/{1}', parameters('registryName'), parameters('name'))]", - "properties": { - "sourceRepository": "[parameters('sourceRepository')]", - "targetRepository": "[parameters('targetRepository')]", - "credentialSetResourceId": "[parameters('credentialSetResourceId')]" - } + "properties": "[if(not(empty(parameters('credentialSetResourceId'))), createObject('sourceRepository', parameters('sourceRepository'), 'targetRepository', parameters('targetRepository'), 'credentialSetResourceId', parameters('credentialSetResourceId')), createObject('sourceRepository', parameters('sourceRepository'), 'targetRepository', parameters('targetRepository')))]" } ], "outputs": { diff --git a/avm/res/container-registry/registry/replication/main.json b/avm/res/container-registry/registry/replication/main.json index beca1e3cec..7014d551dd 100644 --- a/avm/res/container-registry/registry/replication/main.json +++ b/avm/res/container-registry/registry/replication/main.json @@ -5,8 +5,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.30.3.12046", - "templateHash": "11507205381257602922" + "version": "0.30.23.60470", + "templateHash": "4997004041066797666" }, "name": "Azure Container Registry (ACR) Replications", "description": "This module deploys an Azure Container Registry (ACR) Replication.", diff --git a/avm/res/container-registry/registry/scope-map/main.json b/avm/res/container-registry/registry/scope-map/main.json index c19212c9a3..5d8ad4d196 100644 --- a/avm/res/container-registry/registry/scope-map/main.json +++ b/avm/res/container-registry/registry/scope-map/main.json @@ -5,8 +5,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.30.3.12046", - "templateHash": "17045733538280748766" + "version": "0.30.23.60470", + "templateHash": "17963190751439748514" }, "name": "Container Registries scopeMaps", "description": "This module deploys an Azure Container Registry (ACR) scopeMap.", diff --git a/avm/res/container-registry/registry/tests/e2e/cache/main.test.bicep b/avm/res/container-registry/registry/tests/e2e/cache/main.test.bicep index c19abf87f1..beca2f30e9 100644 --- a/avm/res/container-registry/registry/tests/e2e/cache/main.test.bicep +++ b/avm/res/container-registry/registry/tests/e2e/cache/main.test.bicep @@ -74,11 +74,16 @@ module testDeployment '../../../main.bicep' = [ ] cacheRules: [ { - name: 'customRule' + name: 'customRuleWithAuth' sourceRepository: 'docker.io/library/hello-world' targetRepository: 'cached-docker-hub/hello-world' credentialSetResourceId: nestedDependencies.outputs.acrCredentialSetResourceId } + { + name: 'customRuleWithoutAuth' + sourceRepository: 'mcr.microsoft.com/bicep/avm/*' + targetRepository: 'avm/*' + } ] } } diff --git a/avm/res/container-registry/registry/webhook/main.json b/avm/res/container-registry/registry/webhook/main.json index d5805e9f69..a39b9d6d70 100644 --- a/avm/res/container-registry/registry/webhook/main.json +++ b/avm/res/container-registry/registry/webhook/main.json @@ -5,8 +5,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.30.3.12046", - "templateHash": "3542060088842117365" + "version": "0.30.23.60470", + "templateHash": "10216591470402784498" }, "name": "Azure Container Registry (ACR) Webhooks", "description": "This module deploys an Azure Container Registry (ACR) Webhook.",