(node *yaml.Node)
| 147 | } |
| 148 | |
| 149 | func (include *Include) UnmarshalYAML(node *yaml.Node) error { |
| 150 | switch node.Kind { |
| 151 | |
| 152 | case yaml.ScalarNode: |
| 153 | var str string |
| 154 | if err := node.Decode(&str); err != nil { |
| 155 | return errors.NewTaskfileDecodeError(err, node) |
| 156 | } |
| 157 | include.Taskfile = str |
| 158 | return nil |
| 159 | |
| 160 | case yaml.MappingNode: |
| 161 | var includedTaskfile struct { |
| 162 | Taskfile string |
| 163 | Dir string |
| 164 | Optional bool |
| 165 | Internal bool |
| 166 | Flatten bool |
| 167 | Aliases []string |
| 168 | Excludes []string |
| 169 | Vars *Vars |
| 170 | Checksum string |
| 171 | } |
| 172 | if err := node.Decode(&includedTaskfile); err != nil { |
| 173 | return errors.NewTaskfileDecodeError(err, node) |
| 174 | } |
| 175 | if strings.TrimSpace(includedTaskfile.Taskfile) == "" && strings.TrimSpace(includedTaskfile.Dir) == "" { |
| 176 | return errors.NewTaskfileDecodeError(nil, node).WithMessage("include must specify taskfile or dir") |
| 177 | } |
| 178 | include.Taskfile = includedTaskfile.Taskfile |
| 179 | include.Dir = includedTaskfile.Dir |
| 180 | include.Optional = includedTaskfile.Optional |
| 181 | include.Internal = includedTaskfile.Internal |
| 182 | include.Aliases = includedTaskfile.Aliases |
| 183 | include.Excludes = includedTaskfile.Excludes |
| 184 | include.AdvancedImport = true |
| 185 | include.Vars = includedTaskfile.Vars |
| 186 | include.Flatten = includedTaskfile.Flatten |
| 187 | include.Checksum = includedTaskfile.Checksum |
| 188 | return nil |
| 189 | } |
| 190 | |
| 191 | return errors.NewTaskfileDecodeError(nil, node).WithTypeMessage("include") |
| 192 | } |
| 193 | |
| 194 | // DeepCopy creates a new instance of IncludedTaskfile and copies |
| 195 | // data by value from the source struct. |
nothing calls this directly
no test coverage detected