MCPcopy Create free account
hub / github.com/cozystack/talm / cloneValues

Function cloneValues

pkg/engine/render_test.go:51–57  ·  view source on GitHub ↗

cloneValues returns a recursive deep copy of the chart values map. maps.Copy is a shallow copy — mutating a nested map or slice in a test would leak into chrt.Values and corrupt subsequent renders. Since chart values consist only of maps, slices, and primitives, a small switch + recursion suffices;

(src map[string]any)

Source from the content-addressed store, hash-verified

49// Since chart values consist only of maps, slices, and primitives,
50// a small switch + recursion suffices; no external dep needed.
51func cloneValues(src map[string]any) map[string]any {
52 dst := make(map[string]any, len(src))
53 for k, v := range src {
54 dst[k] = deepClone(v)
55 }
56 return dst
57}
58
59func deepClone(v any) any {
60 switch x := v.(type) {

Calls 1

deepCloneFunction · 0.85

Tested by

no test coverage detected