1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-06 17:40:58 +00:00
forgejo-runner/act/runner/step_factory.go

46 lines
1.1 KiB
Go

package runner
import (
"fmt"
"code.forgejo.org/forgejo/runner/act/model"
)
type stepFactory interface {
newStep(step *model.Step, rc *RunContext) (step, error)
}
type stepFactoryImpl struct{}
func (sf *stepFactoryImpl) newStep(stepModel *model.Step, rc *RunContext) (step, error) {
switch stepModel.Type() {
case model.StepTypeInvalid:
return nil, fmt.Errorf("Invalid run/uses syntax for job:%s step:%+v", rc.Run, stepModel)
case model.StepTypeRun:
return &stepRun{
Step: stepModel,
RunContext: rc,
}, nil
case model.StepTypeUsesActionLocal:
return &stepActionLocal{
Step: stepModel,
RunContext: rc,
readAction: readActionImpl,
runAction: runActionImpl,
}, nil
case model.StepTypeUsesActionRemote:
return &stepActionRemote{
Step: stepModel,
RunContext: rc,
readAction: readActionImpl,
runAction: runActionImpl,
}, nil
case model.StepTypeUsesDockerURL:
return &stepDocker{
Step: stepModel,
RunContext: rc,
}, nil
}
return nil, fmt.Errorf("Unable to determine how to run job:%s step:%+v", rc.Run, stepModel)
}