Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Print valid JSON/YAML when workflow list empty #10873 #11681

Merged
merged 1 commit into from
Aug 26, 2023
Merged

fix: Print valid JSON/YAML when workflow list empty #10873 #11681

merged 1 commit into from
Aug 26, 2023

Conversation

Goorzhel
Copy link
Contributor

@Goorzhel Goorzhel commented Aug 26, 2023

Fixes #10873.

Motivation

Tools with -o json are expected to output valid JSON. Same for YAML.

Modifications

I kept the change minimal. Since PrintWorkflows fails fast at len(workflows) == 0, I stuck with that.

Verification

$ make dist/argo-linux-amd64
<...>
$ dist/argo-linux-amd64 -v list -o json
DEBU[2023-08-25T23:26:48.261Z] CLI version                                   version="{latest+9cc740c.dirty 2023-08-26T05:59:15Z 9cc740cc49a9ff91a955bd1356dbacb8dcf4fe50 untagged dirty go1.20.4 gc linux/amd64}"
DEBU[2023-08-25T23:26:48.261Z] Client options                                opts="(argoServerOpts=(url=,path=,secure=true,insecureSkipVerify=false,http=false),instanceID=)"
I0825 23:26:48.263036 1745777 loader.go:372] Config loaded from file:  /home/ag/.kube/config
I0825 23:26:48.264209 1745777 loader.go:372] Config loaded from file:  /home/ag/.kube/config
DEBU[2023-08-25T23:26:48.264Z]                                               listOpts="&ListOptions{LabelSelector:,FieldSelector:,Watch:false,ResourceVersion:,TimeoutSeconds:nil,Limit:0,Continue:,AllowWatchBookmarks:false,ResourceVersionMatch:,}"
I0825 23:26:48.270409 1745777 round_trippers.go:553] GET https://<KUBE_API>:6443/apis/argoproj.io/v1alpha1/namespaces/default/workflows?labelSelector=%21workflows.argoproj.io%2Fcontroller-instanceid 200 OK in 5 milliseconds
DEBU[2023-08-25T23:26:48.273Z] CanI                                          name= namespace=default resource=workflows verb=list
I0825 23:26:48.275370 1745777 round_trippers.go:553] POST https://<KUBE_API>:6443/apis/authorization.k8s.io/v1/selfsubjectaccessreviews 201 Created in 1 milliseconds
DEBU[2023-08-25T23:26:48.275Z] CanI                                          name= namespace=default resource=workflows status="{true false  }" verb=list
[]

Fixes #10873.

Signed-off-by: Antonio Gurgel <antonio@goorzhel.com>
@Goorzhel Goorzhel changed the title fix: Print valid JSON/YAML when workflow list empty (fixes #10873) fix: Print valid JSON/YAML when workflow list empty #10873 Aug 26, 2023
@terrytangyuan terrytangyuan marked this pull request as ready for review August 26, 2023 11:43
@terrytangyuan terrytangyuan merged commit cb8dbbc into argoproj:master Aug 26, 2023
24 checks passed
@agilgur5 agilgur5 added the area/cli The `argo` CLI label Aug 27, 2023
dpadhiar pushed a commit to dpadhiar/argo-workflows that referenced this pull request May 9, 2024
…rgoproj#11681)

Signed-off-by: Dillen Padhiar <dillen_padhiar@intuit.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli The `argo` CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

argo list -o json should output JSON when no workflows found
3 participants