UnmarshalYAML implements the yaml.Unmarshaler interface.
(node *yaml.Node)
| 116 | |
| 117 | // UnmarshalYAML implements the yaml.Unmarshaler interface. |
| 118 | func (includes *Includes) UnmarshalYAML(node *yaml.Node) error { |
| 119 | if includes == nil || includes.om == nil { |
| 120 | *includes = *NewIncludes() |
| 121 | } |
| 122 | switch node.Kind { |
| 123 | case yaml.MappingNode: |
| 124 | // NOTE: orderedmap does not have an unmarshaler, so we have to decode |
| 125 | // the map manually. We increment over 2 values at a time and assign |
| 126 | // them as a key-value pair. |
| 127 | for i := 0; i < len(node.Content); i += 2 { |
| 128 | keyNode := node.Content[i] |
| 129 | valueNode := node.Content[i+1] |
| 130 | |
| 131 | // Decode the value node into an Include struct |
| 132 | var v Include |
| 133 | if err := valueNode.Decode(&v); err != nil { |
| 134 | return errors.NewTaskfileDecodeError(err, node) |
| 135 | } |
| 136 | |
| 137 | // Set the include namespace |
| 138 | v.Namespace = keyNode.Value |
| 139 | |
| 140 | // Add the include to the ordered map |
| 141 | includes.Set(keyNode.Value, &v) |
| 142 | } |
| 143 | return nil |
| 144 | } |
| 145 | |
| 146 | return errors.NewTaskfileDecodeError(nil, node).WithTypeMessage("includes") |
| 147 | } |
| 148 | |
| 149 | func (include *Include) UnmarshalYAML(node *yaml.Node) error { |
| 150 | switch node.Kind { |
nothing calls this directly
no test coverage detected