in codecatalyst-runner/pkg/workflows/workflow_plans_provider.go [112:177]
func (wpp *workflowPlansProvider) planAction(ctx context.Context, actionName string, action *Action) (runner.Plan, error) {
if wpp.action != "" && wpp.action != actionName {
return nil, nil
}
log.Ctx(ctx).Debug().Msgf("creating action plan for action %s", action.Identifier)
var plan runner.Plan
var err error
var actionSpec *actions.Action
var steps []string
actionIdentifierParts := strings.Split(action.Identifier, "@")
switch actionIdentifierParts[0] {
case ".":
actionSpec, err = actions.Load(wpp.workingDir)
if err != nil {
return nil, fmt.Errorf("unable to load action file '%s': %w", wpp.workingDir, err)
}
case "aws/build", "aws/managed-test":
var runs actions.Runs
runs = actions.Runs{
Using: actions.UsingTypeDocker,
Image: actions.CodeCatalystImage(),
Entrypoint: "/bin/echo",
}
outputs := actions.Outputs{
Variables: make(map[string]actions.Output),
}
for _, output := range action.Outputs.Variables {
outputs.Variables[output] = actions.Output{}
}
actionSpec = &actions.Action{
SchemaVersion: "1.0",
ID: actionIdentifierParts[0],
Name: actionIdentifierParts[0],
Version: actionIdentifierParts[1],
Runs: runs,
Outputs: outputs,
}
steps = make([]string, 0)
if configSteps, ok := action.Configuration["Steps"].([]interface{}); ok {
for _, step := range configSteps {
steps = append(steps, step.(map[interface{}]interface{})["Run"].(string))
}
}
case "aws/github-actions-runner":
return nil, fmt.Errorf("GitHub actions are not currently supported")
default:
actionSpec, err = loadRemoteAction(ctx, actionIdentifierParts[0])
if err != nil {
return nil, err
}
}
log.Ctx(ctx).Debug().Msgf("actionspec=%+v", actionSpec)
if plan, err = actions.NewActionPlan(&actions.NewActionPlanParams{
Action: actionSpec,
ExecutionType: wpp.executionType,
WorkingDir: wpp.workingDir,
ID: actionName,
Steps: steps,
DependsOn: action.DependsOn,
}); err != nil {
return nil, fmt.Errorf("unable to create new action plan: %w", err)
}
err = applyInputs(plan.EnvironmentConfiguration(), action, actionSpec)
return plan, err
}