Skip to content

Commit

Permalink
refactor: remove nesting during dry-run of argo delete (#11596)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Gilgur <[email protected]>
  • Loading branch information
agilgur5 committed Aug 17, 2023
1 parent 1cc53f9 commit bda561e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cmd/argo/commands/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,18 @@ func NewDeleteCommand() *cobra.Command {
}

for _, wf := range workflows {
if !dryRun {
_, err := serviceClient.DeleteWorkflow(ctx, &workflowpkg.WorkflowDeleteRequest{Name: wf.Name, Namespace: wf.Namespace, Force: force})
if err != nil && status.Code(err) == codes.NotFound {
fmt.Printf("Workflow '%s' not found\n", wf.Name)
continue
}
errors.CheckError(err)
fmt.Printf("Workflow '%s' deleted\n", wf.Name)
} else {
if dryRun {
fmt.Printf("Workflow '%s' deleted (dry-run)\n", wf.Name)
continue
}

_, err := serviceClient.DeleteWorkflow(ctx, &workflowpkg.WorkflowDeleteRequest{Name: wf.Name, Namespace: wf.Namespace, Force: force})
if err != nil && status.Code(err) == codes.NotFound {
fmt.Printf("Workflow '%s' not found\n", wf.Name)
continue
}
errors.CheckError(err)
fmt.Printf("Workflow '%s' deleted\n", wf.Name)
}
},
}
Expand Down

0 comments on commit bda561e

Please sign in to comment.