MCPcopy
hub / github.com/carvel-dev/ytt / applySchemaDefaults

Method applySchemaDefaults

pkg/schema/assign.go:62–76  ·  view source on GitHub ↗
(foundKeys []interface{}, chk TypeCheck, mapNode *yamlmeta.Map)

Source from the content-addressed store, hash-verified

60}
61
62func (m *MapType) applySchemaDefaults(foundKeys []interface{}, chk TypeCheck, mapNode *yamlmeta.Map) {
63 for _, item := range m.Items {
64 if contains(foundKeys, item.Key) {
65 continue
66 }
67
68 val := item.GetDefaultValue()
69 childCheck := item.AssignTypeTo(val.(*yamlmeta.MapItem))
70 chk.Violations = append(chk.Violations, childCheck.Violations...)
71 err := mapNode.AddValue(val)
72 if err != nil {
73 panic(fmt.Sprintf("Internal inconsistency: adding map item: %s", err))
74 }
75 }
76}
77
78func contains(haystack []interface{}, needle interface{}) bool {
79 for _, key := range haystack {

Callers 1

AssignTypeToMethod · 0.95

Calls 4

containsFunction · 0.70
GetDefaultValueMethod · 0.65
AssignTypeToMethod · 0.65
AddValueMethod · 0.65

Tested by

no test coverage detected