You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
635 B
39 lines
635 B
package pipelines
|
|
|
|
import "errors"
|
|
|
|
type StepType int
|
|
|
|
const (
|
|
TypeResizeImageStep StepType = iota
|
|
TypeCompressImageStep
|
|
)
|
|
|
|
type Step struct {
|
|
Name string `json:"name" faker:"name"`
|
|
Type StepType `json:"type" faker:"-"`
|
|
}
|
|
|
|
func (s Step) Translate() (IExecutableStep, error) {
|
|
var step IExecutableStep
|
|
switch s.GetType() {
|
|
case TypeResizeImageStep:
|
|
step = ResizeImageStep{s}
|
|
case TypeCompressImageStep:
|
|
step = CompressImageStep{s}
|
|
}
|
|
|
|
if step == nil {
|
|
return nil, errors.New("invalid type")
|
|
}
|
|
|
|
return step, nil
|
|
}
|
|
|
|
func (s Step) GetType() StepType {
|
|
return s.Type
|
|
}
|
|
|
|
func (s Step) GetName() string {
|
|
return s.Name
|
|
}
|