package pipelines import ( "encoding/json" "errors" ) type StepType int const ( TypeResizeImageStep StepType = iota TypeCompressImageStep ) type Step struct { Name string `json:"name" faker:"name"` Type StepType `json:"type" faker:"-"` Options json.RawMessage `json:"options"` } func (s Step) Translate() (IExecutableStep, error) { switch s.GetType() { case TypeResizeImageStep: step := ResizeImageStep{} if err := json.Unmarshal(s.Options, &step.Options); err != nil { return nil, err } return step, nil //case TypeCompressImageStep: // step = CompressImageStep{s} } return nil, errors.New("invalid type") } func (s Step) GetType() StepType { return s.Type } func (s Step) GetName() string { return s.Name }