From 4539b89d1967324f1d80e7031663ca6ebeed416b Mon Sep 17 00:00:00 2001 From: Gerd Oberlechner Date: Wed, 27 Nov 2024 08:20:51 +0100 Subject: [PATCH] don't uppercase scope binding replacement vars Signed-off-by: Gerd Oberlechner --- tooling/templatize/pkg/ev2/mapping.go | 2 +- tooling/templatize/pkg/ev2/mapping_test.go | 20 ++++++++-------- tooling/templatize/pkg/ev2/utils_test.go | 24 +++++++++---------- ...reprocessFileForEV2ScopeBinding.bicepparam | 4 ++-- ...elineForEV2ev2-precompiled-test.bicepparam | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tooling/templatize/pkg/ev2/mapping.go b/tooling/templatize/pkg/ev2/mapping.go index 8b06532e9..0fe3c3df6 100644 --- a/tooling/templatize/pkg/ev2/mapping.go +++ b/tooling/templatize/pkg/ev2/mapping.go @@ -21,7 +21,7 @@ func EV2Mapping(input config.Variables, prefix []string) (map[string]string, map } replaced[key] = replacement } else { - placeholder := fmt.Sprintf("__%s__", strings.ToUpper(strings.Join(nestedKey, "_"))) + placeholder := fmt.Sprintf("__%s__", strings.Join(nestedKey, "_")) output[placeholder] = strings.Join(nestedKey, ".") replaced[key] = placeholder } diff --git a/tooling/templatize/pkg/ev2/mapping_test.go b/tooling/templatize/pkg/ev2/mapping_test.go index de7240431..e1d9912ae 100644 --- a/tooling/templatize/pkg/ev2/mapping_test.go +++ b/tooling/templatize/pkg/ev2/mapping_test.go @@ -21,19 +21,19 @@ func TestMapping(t *testing.T) { }, } expectedFlattened := map[string]string{ - "__KEY1__": "key1", - "__KEY2__": "key2", - "__KEY3__": "key3", - "__PARENT_NESTED__": "parent.nested", - "__PARENT_DEEPER_DEEPEST__": "parent.deeper.deepest", + "__key1__": "key1", + "__key2__": "key2", + "__key3__": "key3", + "__parent_nested__": "parent.nested", + "__parent_deeper_deepest__": "parent.deeper.deepest", } expectedReplace := map[string]interface{}{ - "key1": "__KEY1__", - "key2": "__KEY2__", - "key3": "__KEY3__", + "key1": "__key1__", + "key2": "__key2__", + "key3": "__key3__", "parent": map[string]interface{}{ - "nested": "__PARENT_NESTED__", - "deeper": map[string]interface{}{"deepest": "__PARENT_DEEPER_DEEPEST__"}, + "nested": "__parent_nested__", + "deeper": map[string]interface{}{"deepest": "__parent_deeper_deepest__"}, }, } flattened, replace := EV2Mapping(testData, []string{}) diff --git a/tooling/templatize/pkg/ev2/utils_test.go b/tooling/templatize/pkg/ev2/utils_test.go index 51fce778a..0a5b15ee6 100644 --- a/tooling/templatize/pkg/ev2/utils_test.go +++ b/tooling/templatize/pkg/ev2/utils_test.go @@ -16,18 +16,18 @@ func TestScopeBindingVariables(t *testing.T) { t.Fatalf("ScopeBindingVariables failed: %v", err) } expectedVars := map[string]string{ - "__AKSNAME__": "$config(aksName)", - "__GLOBALRG__": "$config(globalRG)", - "__IMAGESYNCRG__": "$config(imageSyncRG)", - "__MAESTRO_HELM_CHART__": "$config(maestro_helm_chart)", - "__MAESTRO_IMAGE__": "$config(maestro_image)", - "__MANAGEMENTCLUSTERRG__": "$config(managementClusterRG)", - "__MANAGEMENTCLUSTERSUBSCRIPTION__": "$config(managementClusterSubscription)", - "__REGION__": "$config(region)", - "__REGIONRG__": "$config(regionRG)", - "__SERVICECLUSTERRG__": "$config(serviceClusterRG)", - "__SERVICECLUSTERSUBSCRIPTION__": "$config(serviceClusterSubscription)", - "__CLUSTERSERVICE_IMAGETAG__": "$config(clusterService.imageTag)", + "__aksName__": "$config(aksName)", + "__globalRG__": "$config(globalRG)", + "__imageSyncRG__": "$config(imageSyncRG)", + "__maestro_helm_chart__": "$config(maestro_helm_chart)", + "__maestro_image__": "$config(maestro_image)", + "__managementClusterRG__": "$config(managementClusterRG)", + "__managementClusterSubscription__": "$config(managementClusterSubscription)", + "__region__": "$config(region)", + "__regionRG__": "$config(regionRG)", + "__serviceClusterRG__": "$config(serviceClusterRG)", + "__serviceClusterSubscription__": "$config(serviceClusterSubscription)", + "__clusterService_imageTag__": "$config(clusterService.imageTag)", } if diff := cmp.Diff(expectedVars, vars); diff != "" { diff --git a/tooling/templatize/testdata/zz_fixture_TestPreprocessFileForEV2ScopeBinding.bicepparam b/tooling/templatize/testdata/zz_fixture_TestPreprocessFileForEV2ScopeBinding.bicepparam index c00e59d52..932498049 100644 --- a/tooling/templatize/testdata/zz_fixture_TestPreprocessFileForEV2ScopeBinding.bicepparam +++ b/tooling/templatize/testdata/zz_fixture_TestPreprocessFileForEV2ScopeBinding.bicepparam @@ -6,5 +6,5 @@ param baseDNSZoneName = 'hcp.osadev.cloud' param baseDNSZoneResourceGroup = 'global' // CS -param csImage = '__CLUSTERSERVICE_IMAGETAG__' -param regionRG = '__REGIONRG__' +param csImage = '__clusterService_imageTag__' +param regionRG = '__regionRG__' diff --git a/tooling/templatize/testdata/zz_fixture_TestProcessPipelineForEV2ev2-precompiled-test.bicepparam b/tooling/templatize/testdata/zz_fixture_TestProcessPipelineForEV2ev2-precompiled-test.bicepparam index feb7facf9..a56162b50 100644 --- a/tooling/templatize/testdata/zz_fixture_TestProcessPipelineForEV2ev2-precompiled-test.bicepparam +++ b/tooling/templatize/testdata/zz_fixture_TestProcessPipelineForEV2ev2-precompiled-test.bicepparam @@ -1 +1 @@ -param regionRG = '__REGIONRG__' \ No newline at end of file +param regionRG = '__regionRG__' \ No newline at end of file