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

Correctly check if a published Tumbleweed image was found #63

Merged
merged 3 commits into from
Jan 4, 2021

Conversation

kalikiana
Copy link
Member

@kalikiana kalikiana commented Dec 29, 2020

  • jq returns null not empty when nothing is found
  • Always use openqa-cli in place of openqa-client
  • Add tests for successful (dry_run) and parse error

See: poo#81492

| jq -r "[.assets[] | select(.name | test(\"Tumbleweed-$arch-$latest_published_tw_build-Tumbleweed\\\\@$machine.qcow\"))] | .[0] | .name")
if ! [[ $qcow ]]; then
if [[ "$qcow" = "null" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the case when the JSON is completely invalid? Maybe $qcow is still empty then. I also remember that I've tested this case and maybe in some cases $qcow is really just empty. I'd simply check for both (null and empty) here to be sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case the JSON is invalid, jq and the script should abort because of bash -e.
But also checking for the empty string doesn't sound like a bad idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the JSON is invalid there's no return value:

parse error: Unfinished JSON term at EOF at line 2, column 0

I can't come up with a case where the return value is the empty string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change makes sense to me. In 9a1ae1d mkittler changed from "sed" to "jq" so instead of an empty string we now get the null value from jq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants