Skip to content

Commit 5669b3d

Browse files
chore(template.go): remove not needed normalizeYAMLValue function
Signed-off-by: Holger Waschke <waschkester@gmail.com>
1 parent 5ef73f1 commit 5669b3d

1 file changed

Lines changed: 0 additions & 36 deletions

File tree

template/template.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -702,39 +702,3 @@ func DeepCopyWithTemplate(value any, tmplTextFunc TemplateFunc) (any, error) {
702702
return value, nil
703703
}
704704
}
705-
706-
// normalizeYAMLValue recursively converts a value decoded by yaml.Unmarshal into
707-
// JSON-compatible types: maps become map[string]any (non-string keys are dropped,
708-
// mirroring DeepCopyWithTemplate) and slices/arrays become []any. Scalar leaves are
709-
// returned unchanged, so values are never re-templated or re-parsed. This keeps a
710-
// rendered JSON payload byte-for-byte faithful instead of reinterpreting string
711-
// values that happen to be valid YAML (see #5302).
712-
func normalizeYAMLValue(value any) any {
713-
if value == nil {
714-
return nil
715-
}
716-
717-
valueMeta := reflect.ValueOf(value)
718-
switch valueMeta.Kind() {
719-
case reflect.Array, reflect.Slice:
720-
converted := make([]any, valueMeta.Len())
721-
for i := range converted {
722-
converted[i] = normalizeYAMLValue(valueMeta.Index(i).Interface())
723-
}
724-
return converted
725-
726-
case reflect.Map:
727-
converted := make(map[string]any, valueMeta.Len())
728-
for _, keyMeta := range valueMeta.MapKeys() {
729-
strKey, isString := keyMeta.Interface().(string)
730-
if !isString {
731-
continue
732-
}
733-
converted[strKey] = normalizeYAMLValue(valueMeta.MapIndex(keyMeta).Interface())
734-
}
735-
return converted
736-
737-
default:
738-
return value
739-
}
740-
}

0 commit comments

Comments
 (0)