Skip to content

Commit

Permalink
patch generate to quote params when missing
Browse files Browse the repository at this point in the history
  • Loading branch information
vhvb1989 committed Oct 24, 2024
1 parent 8fd80cb commit 791c3a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cli/azd/pkg/apphost/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,13 @@ func (b *infraGenerator) buildDeployBlock(
}
}
}

// make sure resolved value is quoted.
// We can't ask EvalString() to quote strings b/c it depends on evalBindingRef() which can return complex
// expressions where each part might be quoted or not.
// Instead, before setting the deploy parameter, we just verify that it's quoted.
if !strings.HasPrefix(resolvedValue, "'") {
resolvedValue = "'" + resolvedValue + "'"
}
manifestCtx.DeployParams[k] = resolvedValue
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using './cache.module.bicep'

param cache_volumes_0_storage = '{{ .Env.SERVICE_CACHE_VOLUME_AZURECONTAINERAPPSAPPHOST8F235654EDCACHEDATA_NAME }}'
param complex = 'tcp:cache/foo'
param host = 'cache'
param outputs_azure_container_apps_environment_id = '{{ .Env.AZURE_CONTAINER_APPS_ENVIRONMENT_ID }}'
param outputs_azure_container_registry_managed_identity_id = '{{ .Env.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID }}'
param outputs_managed_identity_client_id = '{{ .Env.MANAGED_IDENTITY_CLIENT_ID }}'
param protocol = 'tcp'

5 changes: 4 additions & 1 deletion cli/azd/pkg/apphost/testdata/aspire-projectv1.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"cache_volumes_0_storage": "{cache.volumes.0.storage}",
"outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}",
"outputs_managed_identity_client_id": "{.outputs.MANAGED_IDENTITY_CLIENT_ID}",
"outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}"
"outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}",
"host": "{cache.bindings.tcp.host}",
"protocol": "{cache.bindings.tcp.protocol}",
"complex": "{cache.bindings.tcp.protocol}:{cache.bindings.tcp.host}/foo"
}
},
"args": [
Expand Down

0 comments on commit 791c3a8

Please sign in to comment.