singularityhub / sregistry-cli

Singularity Global Client for container management
https://singularityhub.github.io/sregistry-cli/
Mozilla Public License 2.0
14 stars 18 forks source link

sregistry: return 1 on error #209

Closed tschoonj closed 5 years ago

tschoonj commented 5 years ago

Is your feature request related to a problem? Please describe.

Hi @vsoch

I am trying to automate getting, pulling and creating an image depending on availability in the bucket using something like:

sregistry get $IMAGE || \
        sregistry pull s3://$IMAGE || ( \
        rm -rf $LOCAL_IMAGE && \
        sudo --preserve-env=SINGULARITY_CACHEDIR,SINGULARITY_TMPDIR singularity build $LOCAL_IMAGE Singularity && \
        sregistry add --name $IMAGE $LOCAL_IMAGE && (\
        sregistry push --name $IMAGE $LOCAL_IMAGE || \
        echo "Could not push to S3 bucket!"))

However this fails, since some sregistry (get, rm, delete, others...) commands don't return 1 (or some other non-zero value) to the shell on error. In fact most don't even print an error message...

Describe the solution you'd like

All sregistry commands should return 1 on failure, in line with what most software does.

I would be more than happy to do this myself, if you agree that this would be an improvement.

vsoch commented 5 years ago

hey @tschoonj ! Most commands should return 1 on error, so if you are hitting an issue it's definitely a bug that needs to be fixed. The bot.exit() function that I use to exit on error by default returns a code of 1. And yes, definitely I'd be open to a pull request for this!

vsoch commented 5 years ago

Something else to try - If you don't want to use the local database, you could export the variable to disable it, and then just pull it to the $PWD instead.