(node *yaml.Node)
| 17 | } |
| 18 | |
| 19 | func (f *For) UnmarshalYAML(node *yaml.Node) error { |
| 20 | switch node.Kind { |
| 21 | |
| 22 | case yaml.ScalarNode: |
| 23 | var from string |
| 24 | if err := node.Decode(&from); err != nil { |
| 25 | return errors.NewTaskfileDecodeError(err, node) |
| 26 | } |
| 27 | f.From = from |
| 28 | return nil |
| 29 | |
| 30 | case yaml.SequenceNode: |
| 31 | var list []any |
| 32 | if err := node.Decode(&list); err != nil { |
| 33 | return errors.NewTaskfileDecodeError(err, node) |
| 34 | } |
| 35 | f.List = list |
| 36 | return nil |
| 37 | |
| 38 | case yaml.MappingNode: |
| 39 | var forStruct struct { |
| 40 | Matrix *Matrix |
| 41 | Var string |
| 42 | Split string |
| 43 | As string |
| 44 | } |
| 45 | if err := node.Decode(&forStruct); err != nil { |
| 46 | return errors.NewTaskfileDecodeError(err, node) |
| 47 | } |
| 48 | if forStruct.Var == "" && forStruct.Matrix.Len() == 0 { |
| 49 | return errors.NewTaskfileDecodeError(nil, node).WithMessage("invalid keys in for") |
| 50 | } |
| 51 | if forStruct.Var != "" && forStruct.Matrix.Len() != 0 { |
| 52 | return errors.NewTaskfileDecodeError(nil, node).WithMessage("cannot use both var and matrix in for") |
| 53 | } |
| 54 | f.Matrix = forStruct.Matrix |
| 55 | f.Var = forStruct.Var |
| 56 | f.Split = forStruct.Split |
| 57 | f.As = forStruct.As |
| 58 | return nil |
| 59 | } |
| 60 | |
| 61 | return errors.NewTaskfileDecodeError(nil, node).WithTypeMessage("for") |
| 62 | } |
| 63 | |
| 64 | func (f *For) DeepCopy() *For { |
| 65 | if f == nil { |
nothing calls this directly
no test coverage detected