hauler-dev / hauler

Airgap Container Swiss Army Knife
https://hauler.dev
Apache License 2.0
122 stars 28 forks source link

Return a non 0 exit code on error #323

Open Morgimiel opened 1 week ago

Morgimiel commented 1 week ago

Is this RFE related to an Existing Problem? If so, please describe:

I have a script that load images to hauler store. If something went wrong, I have no error exit code to early exit my script.

-

Describe Proposed Solution(s):

We should have an exit code > 0 if something went wrong during a process. For exemple, my hauler store add image command fails because of a bad credentials but I still have exit code 0.

-

Describe Possible Alternatives:

-

Additional Context:

-

dweomer commented 4 days ago

Looks like you may have been bit by this recent change:

I think the resolution to should be a flag/envvar that kicks Hauler into the "legacy" fail-fast mode. Something like --failfast with a default of false with value of $HAULER_FAILFAST parsed for truthiness as env override.


@Morgimiel can you provide a simple example of a script that you expect to fail but does not?

Morgimiel commented 3 days ago

I agree with your proposal. A flag to optionnally fail on error seems OK to me. My script is pretty simple:

helm template myproject | grep image: | tr -d ' "' | sed -nr 's/^image:(.*)$/\1/p' | sort -u | xargs -I {} hauler store add image {}

I want it to fail if any of the add image command fails.

PS: It would be a great feature to have hauler store add chart command have an option to find docker images within in and add them to the store :D. But thats purely bonus ;)