Skip to content

Commit 59bbbf2

Browse files
authored
feat(workflow-run): Ensure not invalid status is passed to CLI (chainloop-dev#870)
Signed-off-by: Javier Rodriguez <[email protected]>
1 parent 63fc169 commit 59bbbf2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/cli/cmd/workflow_workflow_run_list.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package cmd
1717

1818
import (
1919
"fmt"
20+
"slices"
2021
"time"
2122

2223
"github.com/chainloop-dev/chainloop/app/cli/cmd/options"
@@ -36,6 +37,13 @@ func newWorkflowWorkflowRunListCmd() *cobra.Command {
3637
Use: "list",
3738
Aliases: []string{"ls"},
3839
Short: "List workflow runs",
40+
PreRunE: func(cmd *cobra.Command, args []string) error {
41+
if status != "" && !slices.Contains(listAvailableWorkflowStatusFlag(), status) {
42+
return fmt.Errorf("invalid status %q, please chose one of: %v", status, listAvailableWorkflowStatusFlag())
43+
}
44+
45+
return nil
46+
},
3947
RunE: func(cmd *cobra.Command, args []string) error {
4048
res, err := action.NewWorkflowRunList(actionOpts).Run(
4149
&action.WorkflowRunListOpts{

0 commit comments

Comments
 (0)