Skip to content

Commit

Permalink
fix(cli): add validate args in delete command (argoproj#4142)
Browse files Browse the repository at this point in the history
  • Loading branch information
gosoon committed Sep 29, 2020
1 parent 45fe517 commit b3682d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/argo/commands/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"fmt"
"os"

"github.com/argoproj/pkg/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -34,6 +35,11 @@ func NewDeleteCommand() *cobra.Command {
argo delete @latest
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 && !(all || allNamespaces || flags.completed || flags.resubmitted || flags.prefix != "" || flags.labels != "" || flags.finishedAfter != "") {
cmd.HelpFunc()(cmd, args)
os.Exit(1)
}

ctx, apiClient := client.NewAPIClient()
serviceClient := apiClient.NewWorkflowServiceClient()
var workflows wfv1.Workflows
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func (s *CLISuite) TestWorkflowDeleteNothing() {
When().
SubmitWorkflow().
RunCli([]string{"delete"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err) {
if assert.EqualError(t, err, "exit status 1") {
assert.NotContains(t, output, "deleted")
}
})
Expand Down

0 comments on commit b3682d4

Please sign in to comment.