in command-runner/pkg/runner/runner.go [18:49]
func newRunner(namespace string, executionType ExecutionType, plan Plan, features ...Feature) common.Executor {
var executor common.Executor
executor = func(ctx context.Context) error {
logPlan("About to execute plan\n", plan)
for _, commandGroup := range plan.CommandGroups() {
id := fmt.Sprintf("%s-%s", namespace, plan.ID())
executor, err := newCommandExecutor(ctx, id, executionType, commandGroup, plan.EnvironmentConfiguration())
if err != nil {
return err
}
for _, command := range commandGroup.Commands {
log.Ctx(ctx).Info().Msgf("⚡️ %s", strings.Join(command, " "))
err := executor.ExecuteCommand(ctx, command)
if err != nil {
if closeErr := executor.Close(true); closeErr != nil {
return errors.Join(err, closeErr)
}
return err
}
}
if err := executor.Close(false); err != nil {
return err
}
}
return nil
}
executor = executor.CatchPanic()
for _, feature := range features {
executor = newFeatureWrapper(feature, plan).Wrap(executor).CatchPanic()
}
return executor
}