summaryrefslogtreecommitdiffstats
path: root/pkg/runner/step_factory.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/runner/step_factory.go')
-rw-r--r--pkg/runner/step_factory.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/pkg/runner/step_factory.go b/pkg/runner/step_factory.go
new file mode 100644
index 0000000..4ac7eaf
--- /dev/null
+++ b/pkg/runner/step_factory.go
@@ -0,0 +1,46 @@
+package runner
+
+import (
+ "fmt"
+
+ "github.com/nektos/act/pkg/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)
+}