Skip to content

Commit

Permalink
Add check for execution_type fields while building and publishing act…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
gostouche committed May 31, 2023
1 parent a4c0df8 commit 4c41616
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
21 changes: 19 additions & 2 deletions commands/actions/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func buildFunc(cmd *cobra.Command, args []string) {
)
os.Exit(1)
}
mustParseAndValidateTriggers(actions)
mustParseAndValidateActions(actions)

tsConfigExists := util.TsConfigExists(actions.Sources)
tsFileExists, tsFile := anyFunctionTsFileExists(actions)
Expand Down Expand Up @@ -175,8 +175,25 @@ func buildFunc(cmd *cobra.Command, args []string) {
logrus.Info(commands.Colorizer.Green("\nBuild completed."))
}

func mustParseAndValidateTriggers(projectActions *actionsModel.ProjectActions) {
func mustParseAndValidateActions(projectActions *actionsModel.ProjectActions) {
for name, spec := range projectActions.Specs {
if spec.ExecutionType != actionsModel.ParallelExecutionType &&
spec.ExecutionType != actionsModel.SequentialExecutionType {
userError.LogErrorf(
"validation of action failed",
userError.NewUserError(
nil,
commands.Colorizer.Sprintf(
"Invalid execution type %s for action %s. Supported values: {%s, %s}",
commands.Colorizer.Bold(commands.Colorizer.Red(spec.ExecutionType)),
commands.Colorizer.Bold(commands.Colorizer.Blue(name)),
commands.Colorizer.Bold(commands.Colorizer.Green(actionsModel.SequentialExecutionType)),
commands.Colorizer.Bold(commands.Colorizer.Green(actionsModel.ParallelExecutionType)),
),
),
)
os.Exit(1)
}
err := spec.Parse()
if err != nil {
userError.LogErrorf(
Expand Down
8 changes: 4 additions & 4 deletions model/actions/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

const (
sequentialExecutionType = "sequential"
parallelExecutionType = "parallel"
SequentialExecutionType = "sequential"
ParallelExecutionType = "parallel"
)

type Action struct {
Expand Down Expand Up @@ -115,9 +115,9 @@ func IsRuntimeSupported(runtime string) bool {

func invocationTypeFromExecution(executionType string) string {
switch executionType {
case sequentialExecutionType:
case SequentialExecutionType:
return "SYNC"
case parallelExecutionType:
case ParallelExecutionType:
return "ASYNC"
default:
return ""
Expand Down

0 comments on commit 4c41616

Please sign in to comment.