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

Method AssignTypeTo

pkg/schema/assign.go:111–124  ·  view source on GitHub ↗

AssignTypeTo assigns this schema metadata to `node`. If `node` is not a yamlmeta.Array, `chk` contains a violation describing the mismatch For each `node`'s yamlmeta.ArrayItem's that cannot be assigned this ArrayType's ArrayItemType, `chk` contains a violation describing the mismatch

(node yamlmeta.Node)

Source from the content-addressed store, hash-verified

109// If `node` is not a yamlmeta.Array, `chk` contains a violation describing the mismatch
110// For each `node`'s yamlmeta.ArrayItem's that cannot be assigned this ArrayType's ArrayItemType, `chk` contains a violation describing the mismatch
111func (a *ArrayType) AssignTypeTo(node yamlmeta.Node) TypeCheck {
112 chk := TypeCheck{}
113 arrayNode, ok := node.(*yamlmeta.Array)
114 if !ok {
115 chk.Violations = append(chk.Violations, NewMismatchedTypeAssertionError(node, a))
116 return chk
117 }
118 SetType(node, a)
119 for _, arrayItem := range arrayNode.Items {
120 childCheck := a.ItemsType.AssignTypeTo(arrayItem)
121 chk.Violations = append(chk.Violations, childCheck.Violations...)
122 }
123 return chk
124}
125
126// AssignTypeTo assigns this schema metadata to `node`.
127//

Callers

nothing calls this directly

Calls 3

SetTypeFunction · 0.85
AssignTypeToMethod · 0.65

Tested by

no test coverage detected