Skip to content

Commit

Permalink
fix: Fix delete --complete (#3278)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Jun 25, 2020
1 parent d5a4807 commit a91cea5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions cmd/argo/commands/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func NewDeleteCommand() *cobra.Command {
argo delete my-wf
# Delete the latest workflow:
argo delete @latest
`,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
8 changes: 3 additions & 5 deletions cmd/argo/commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func listWorkflows(ctx context.Context, serviceClient workflowpkg.WorkflowServic
listOpts := &metav1.ListOptions{
Limit: flags.chunkSize,
}
labelSelector := labels.NewSelector()
labelSelector, err := labels.Parse(flags.labels)
errors.CheckError(err)
if len(flags.status) != 0 {
req, _ := labels.NewRequirement(common.LabelKeyPhase, selection.In, flags.status)
if req != nil {
Expand All @@ -94,10 +95,7 @@ func listWorkflows(ctx context.Context, serviceClient workflowpkg.WorkflowServic
req, _ := labels.NewRequirement(common.LabelKeyCompleted, selection.NotEquals, []string{"true"})
labelSelector = labelSelector.Add(*req)
}
if listOpts.LabelSelector = labelSelector.String(); listOpts.LabelSelector != "" {
listOpts.LabelSelector = listOpts.LabelSelector + ","
}
listOpts.LabelSelector = listOpts.LabelSelector + flags.labels
listOpts.LabelSelector = labelSelector.String()
listOpts.FieldSelector = flags.fields
var workflows wfv1.Workflows
for {
Expand Down
12 changes: 9 additions & 3 deletions cmd/argo/commands/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,26 @@ import (
)

func Test_listWorkflows(t *testing.T) {
t.Run("Nothing", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{}, listFlags{})
if assert.NoError(t, err) {
assert.NotNil(t, workflows)
}
})
t.Run("Status", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{LabelSelector: "workflows.argoproj.io/phase in (Pending,Running),"}, listFlags{status: []string{"Running", "Pending"}})
workflows, err := list(&metav1.ListOptions{LabelSelector: "workflows.argoproj.io/phase in (Pending,Running)"}, listFlags{status: []string{"Running", "Pending"}})
if assert.NoError(t, err) {
assert.NotNil(t, workflows)
}
})
t.Run("Completed", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{LabelSelector: "workflows.argoproj.io/completed=true,"}, listFlags{completed: true})
workflows, err := list(&metav1.ListOptions{LabelSelector: "workflows.argoproj.io/completed=true"}, listFlags{completed: true})
if assert.NoError(t, err) {
assert.NotNil(t, workflows)
}
})
t.Run("Running", func(t *testing.T) {
workflows, err := list(&metav1.ListOptions{LabelSelector: "workflows.argoproj.io/completed!=true,"}, listFlags{running: true})
workflows, err := list(&metav1.ListOptions{LabelSelector: "workflows.argoproj.io/completed!=true"}, listFlags{running: true})
if assert.NoError(t, err) {
assert.NotNil(t, workflows)
}
Expand Down
2 changes: 1 addition & 1 deletion server/workflow/workflow_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func (s *workflowServer) getWorkflow(wfClient versioned.Interface, namespace str
if err != nil {
return nil, err
}
log.Infof("Resolved alias %s to workflow %s.\n", latestAlias, latest.Name)
log.Debugf("Resolved alias %s to workflow %s.\n", latestAlias, latest.Name)
return latest, nil
}
wf, err := wfClient.ArgoprojV1alpha1().Workflows(namespace).Get(name, options)
Expand Down

0 comments on commit a91cea5

Please sign in to comment.