Skip to content

Commit

Permalink
don't uppercase scope binding replacement vars (#901)
Browse files Browse the repository at this point in the history
Signed-off-by: Gerd Oberlechner <[email protected]>
  • Loading branch information
geoberle authored Nov 27, 2024
1 parent 9e7806f commit 4c9062b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion tooling/templatize/pkg/ev2/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 10 additions & 10 deletions tooling/templatize/pkg/ev2/mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down
24 changes: 12 additions & 12 deletions tooling/templatize/pkg/ev2/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__'
Original file line number Diff line number Diff line change
@@ -1 +1 @@
param regionRG = '__REGIONRG__'
param regionRG = '__regionRG__'

0 comments on commit 4c9062b

Please sign in to comment.