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

Method AssignTypeTo

pkg/schema/assign.go:130–144  ·  view source on GitHub ↗

AssignTypeTo assigns this schema metadata to `node`. If `node` is not a yamlmeta.ArrayItem, `chk` contains a violation describing the mismatch If `node`'s value is not of the same structure (i.e. yamlmeta.Node type), `chk` contains a violation describing this mismatch

(node yamlmeta.Node)

Source from the content-addressed store, hash-verified

128// If `node` is not a yamlmeta.ArrayItem, `chk` contains a violation describing the mismatch
129// If `node`'s value is not of the same structure (i.e. yamlmeta.Node type), `chk` contains a violation describing this mismatch
130func (a *ArrayItemType) AssignTypeTo(node yamlmeta.Node) TypeCheck {
131 chk := TypeCheck{}
132 arrayItem, ok := node.(*yamlmeta.ArrayItem)
133 if !ok {
134 chk.Violations = append(chk.Violations, NewMismatchedTypeAssertionError(node, a))
135 return chk
136 }
137 SetType(node, a)
138 valueNode, isNode := arrayItem.Value.(yamlmeta.Node)
139 if isNode {
140 childCheck := a.ValueType.AssignTypeTo(valueNode)
141 chk.Violations = append(chk.Violations, childCheck.Violations...)
142 } // else, is scalar
143 return chk
144}
145
146// AssignTypeTo returns a violation describing the type mismatch, given that ScalarType will never accept a yamlmeta.Node
147func (s *ScalarType) AssignTypeTo(node yamlmeta.Node) TypeCheck {

Callers

nothing calls this directly

Calls 3

SetTypeFunction · 0.85
AssignTypeToMethod · 0.65

Tested by

no test coverage detected