AssignTypeTo assigns this schema metadata to `node`. If `node` is not a yamlmeta.Map, `chk` contains a violation describing the mismatch If `node`'s yamlmeta.MapItem's cannot be assigned their corresponding MapItemType, `chk` contains a violation describing the mismatch If `node` is missing any yam
(node yamlmeta.Node)
| 36 | // If `node`'s yamlmeta.MapItem's cannot be assigned their corresponding MapItemType, `chk` contains a violation describing the mismatch |
| 37 | // If `node` is missing any yamlmeta.MapItem's specified in this MapType, they are added to `node`. |
| 38 | func (m *MapType) AssignTypeTo(node yamlmeta.Node) TypeCheck { |
| 39 | chk := TypeCheck{} |
| 40 | mapNode, ok := node.(*yamlmeta.Map) |
| 41 | if !ok { |
| 42 | chk.Violations = append(chk.Violations, NewMismatchedTypeAssertionError(node, m)) |
| 43 | return chk |
| 44 | } |
| 45 | var foundKeys []interface{} |
| 46 | SetType(node, m) |
| 47 | for _, mapItem := range mapNode.Items { |
| 48 | for _, itemType := range m.Items { |
| 49 | if mapItem.Key == itemType.Key { |
| 50 | foundKeys = append(foundKeys, itemType.Key) |
| 51 | childCheck := itemType.AssignTypeTo(mapItem) |
| 52 | chk.Violations = append(chk.Violations, childCheck.Violations...) |
| 53 | break |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | m.applySchemaDefaults(foundKeys, chk, mapNode) |
| 59 | return chk |
| 60 | } |
| 61 | |
| 62 | func (m *MapType) applySchemaDefaults(foundKeys []interface{}, chk TypeCheck, mapNode *yamlmeta.Map) { |
| 63 | for _, item := range m.Items { |
nothing calls this directly
no test coverage detected