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

Method AssignTypeTo

pkg/schema/assign.go:17–31  ·  view source on GitHub ↗

AssignTypeTo assigns this schema metadata to `node`. If `node` is not a yamlmeta.Document, `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

15// If `node` is not a yamlmeta.Document, `chk` contains a violation describing the mismatch
16// If `node`'s value is not of the same structure (i.e. yamlmeta.Node type), `chk` contains a violation describing this mismatch
17func (t *DocumentType) AssignTypeTo(node yamlmeta.Node) TypeCheck {
18 chk := TypeCheck{}
19 doc, ok := node.(*yamlmeta.Document)
20 if !ok {
21 chk.Violations = append(chk.Violations, NewMismatchedTypeAssertionError(node, t))
22 return chk
23 }
24 SetType(doc, t)
25 valueNode, isNode := doc.Value.(yamlmeta.Node)
26 if isNode {
27 childCheck := t.ValueType.AssignTypeTo(valueNode)
28 chk.Violations = append(chk.Violations, childCheck.Violations...)
29 } // else, is a scalar
30 return chk
31}
32
33// AssignTypeTo assigns this schema metadata to `node`.
34//

Callers

nothing calls this directly

Calls 3

SetTypeFunction · 0.85
AssignTypeToMethod · 0.65

Tested by

no test coverage detected