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

argo list -o json should output JSON when no workflows found #10873

Closed
Goorzhel opened this issue Apr 11, 2023 · 2 comments · Fixed by #11681
Closed

argo list -o json should output JSON when no workflows found #10873

Goorzhel opened this issue Apr 11, 2023 · 2 comments · Fixed by #11681
Labels
area/cli The `argo` CLI type/feature Feature request

Comments

@Goorzhel
Copy link
Contributor

Summary

Expected:

bash-5.2# argo list -o json
[]

Actual:

bash-5.2# argo list -o json
No workflows found

Which causes:

bash-5.2# argo list -o json | jq .
parse error: Invalid numeric literal at line 1, column 3

Use Cases

I have a Bash script that pipes to jq to check for workflows with parameters identical to the one it's about to submit -- if there is one, skip submission.

submit() {
  # snip
  existing=$(argo list -o json | \
    jq -r '.[]
      | select(.status.phase=="Running" or .status.phase=="Succeeded")
      | .spec.arguments.parameters[]
      | select(.name=="filename")
      | .value')

  if grep -qF "$filename" <<< "$existing"; then
    echo "Found existing workflow for $filename"
    return
  fi
  # snip
}

Perhaps there is a better way, but this is the one I've cobbled together.

Version

bash-5.2# argo version
argo: v3.4.6
  BuildDate: 2023-03-31T19:53:49Z
  GitCommit: 988706dd131cf98808f09fb7cc03780e2af94c73
  GitTreeState: clean
  GitTag: v3.4.6
  GoVersion: go1.18.10
  Compiler: gc
  Platform: linux/amd64

Message from the maintainers:

Love this enhancement proposal? Give it a 👍. We prioritise the proposals with the most 👍.

@Goorzhel Goorzhel added the type/feature Feature request label Apr 11, 2023
@OneCricketeer
Copy link

OneCricketeer commented Apr 11, 2023

You could check $? value if it's zero as a workaround. For example, you're not handling error case where Argo workflow server is down.

@Goorzhel
Copy link
Contributor Author

In a sense, I am: I accidentally left out the script's set -e in that snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli The `argo` CLI type/feature Feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants