Skip to content

Commit

Permalink
feat(cli): Support deleting resubmitted workflows (#3554)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrytangyuan authored Jul 24, 2020
1 parent 1b757ea commit cdc935a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cmd/argo/commands/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewDeleteCommand() *cobra.Command {
dryRun bool
)
var command = &cobra.Command{
Use: "delete [--dry-run] [WORKFLOW...|[--all] [--older] [--completed] [--prefix PREFIX] [--selector SELECTOR]]",
Use: "delete [--dry-run] [WORKFLOW...|[--all] [--older] [--completed] [--resubmitted] [--prefix PREFIX] [--selector SELECTOR]]",
Short: "delete workflows",
Example: `# Delete a workflow:
Expand All @@ -45,7 +45,7 @@ func NewDeleteCommand() *cobra.Command {
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: flags.namespace},
})
}
if all || flags.completed || flags.prefix != "" || flags.labels != "" {
if all || flags.completed || flags.resubmitted || flags.prefix != "" || flags.labels != "" {
listed, err := listWorkflows(ctx, serviceClient, flags)
errors.CheckError(err)
workflows = append(workflows, listed...)
Expand All @@ -69,6 +69,7 @@ func NewDeleteCommand() *cobra.Command {
command.Flags().BoolVar(&allNamespaces, "all-namespaces", false, "Delete workflows from all namespaces")
command.Flags().BoolVar(&all, "all", false, "Delete all workflows")
command.Flags().BoolVar(&flags.completed, "completed", false, "Delete completed workflows")
command.Flags().BoolVar(&flags.resubmitted, "resubmitted", false, "Delete resubmitted workflows")
command.Flags().StringVar(&flags.prefix, "prefix", "", "Delete workflows by prefix")
command.Flags().StringVar(&flags.finishedAfter, "older", "", "Delete completed workflows finished before the specified duration (e.g. 10m, 3h, 1d)")
command.Flags().StringVarP(&flags.labels, "selector", "l", "", "Selector (label query) to filter on, not including uninitialized ones")
Expand Down
3 changes: 2 additions & 1 deletion docs/cli/argo_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ delete workflows
delete workflows

```
argo delete [--dry-run] [WORKFLOW...|[--all] [--older] [--completed] [--prefix PREFIX] [--selector SELECTOR]] [flags]
argo delete [--dry-run] [WORKFLOW...|[--all] [--older] [--completed] [--resubmitted] [--prefix PREFIX] [--selector SELECTOR]] [flags]
```

### Examples
Expand All @@ -33,6 +33,7 @@ argo delete [--dry-run] [WORKFLOW...|[--all] [--older] [--completed] [--prefix P
-h, --help help for delete
--older string Delete completed workflows finished before the specified duration (e.g. 10m, 3h, 1d)
--prefix string Delete workflows by prefix
--resubmitted Delete resubmitted workflows
-l, --selector string Selector (label query) to filter on, not including uninitialized ones
```

Expand Down
25 changes: 25 additions & 0 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,31 @@ func (s *CLISuite) TestWorkflowDeleteCompleted() {
})
}

func (s *CLISuite) TestWorkflowDeleteResubmitted() {
(s.Given().
Workflow("@testdata/exit-1.yaml").
When().
SubmitWorkflow().
WaitForWorkflow(30*time.Second).
Given().
RunCli([]string{"resubmit", "--memoized", "exit-1"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err) {
assert.Contains(t, output, "Name:")
assert.Contains(t, output, "Namespace:")
assert.Contains(t, output, "ServiceAccount:")
assert.Contains(t, output, "Status:")
assert.Contains(t, output, "Created:")
}
}).
When().
Given().
RunCli([]string{"delete", "--resubmitted", "-l", "argo-e2e"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err) {
assert.Contains(t, output, "deleted")
}
}))
}

func (s *CLISuite) TestWorkflowDeleteOlder() {
s.Given().
Workflow("@smoke/basic.yaml").
Expand Down

0 comments on commit cdc935a

Please sign in to comment.