github.com/ixpectus/declarate@v0.0.0-20240422152255-708027d7c068/run/config.go (about) 1 package run 2 3 import ( 4 "fmt" 5 6 "github.com/ixpectus/declarate/contract" 7 ) 8 9 type runConfig struct { 10 Name string `yaml:"name,omitempty"` 11 Steps []runConfig `yaml:"steps,omitempty"` 12 Vars contract.Vars 13 Variables map[string]string `yaml:"variables"` 14 VariablesPersistent map[string]string `yaml:"variables_persistent"` 15 Commands []contract.Doer 16 Builders []contract.CommandBuilder 17 Poll *Poll `yaml:"poll,omitempty"` 18 Condition string `yaml:"condition,omitempty"` 19 } 20 21 func (u *runConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { 22 type raw runConfig 23 if err := unmarshal((*raw)(u)); err != nil { 24 return err 25 } 26 u.Commands = []contract.Doer{} 27 for _, v := range builders { 28 b, err := v.Build(unmarshal) 29 if err != nil { 30 return fmt.Errorf("unmarshal build err: %w", err) 31 } 32 if b != nil { 33 u.Commands = append(u.Commands, b) 34 } 35 } 36 return nil 37 }