github.1485827954.workers.dev/nektos/act@v0.2.63/pkg/runner/step_factory.go (about)

     1  package runner
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/nektos/act/pkg/model"
     7  )
     8  
     9  type stepFactory interface {
    10  	newStep(step *model.Step, rc *RunContext) (step, error)
    11  }
    12  
    13  type stepFactoryImpl struct{}
    14  
    15  func (sf *stepFactoryImpl) newStep(stepModel *model.Step, rc *RunContext) (step, error) {
    16  	switch stepModel.Type() {
    17  	case model.StepTypeInvalid:
    18  		return nil, fmt.Errorf("Invalid run/uses syntax for job:%s step:%+v", rc.Run, stepModel)
    19  	case model.StepTypeRun:
    20  		return &stepRun{
    21  			Step:       stepModel,
    22  			RunContext: rc,
    23  		}, nil
    24  	case model.StepTypeUsesActionLocal:
    25  		return &stepActionLocal{
    26  			Step:       stepModel,
    27  			RunContext: rc,
    28  			readAction: readActionImpl,
    29  			runAction:  runActionImpl,
    30  		}, nil
    31  	case model.StepTypeUsesActionRemote:
    32  		return &stepActionRemote{
    33  			Step:       stepModel,
    34  			RunContext: rc,
    35  			readAction: readActionImpl,
    36  			runAction:  runActionImpl,
    37  		}, nil
    38  	case model.StepTypeUsesDockerURL:
    39  		return &stepDocker{
    40  			Step:       stepModel,
    41  			RunContext: rc,
    42  		}, nil
    43  	}
    44  
    45  	return nil, fmt.Errorf("Unable to determine how to run job:%s step:%+v", rc.Run, stepModel)
    46  }