Closed tschoonj closed 5 years ago
Hmm, I disagree here - I think the application shouldn't be allowed to do a mkdir p, is it not reasonable to ask the user to select a folder that exists?
What we should do, however, is do a check and exit gracefully instead of spitting all that out. Let me know your thoughts.
I agree that at the very least a graceful exit should happen.
Does this also occur when SREGISTRY_DATABASE
is not set: is $HOME/.sregistry
automatically created?
If it's not set, the credentials file defaults to $HOME/.sregistry
for credentials, and $HOME/.singularity/sregistry.db
for the sqlite database. Those should be taken care of for creation. You can see the flow of logic in https://github.com/singularityhub/sregistry-cli/blob/master/sregistry/defaults.py#L103 and then init_db is called here and the function is here (so that's where you'd want to check for the path and gracefully exit). And then interaction with the credentials file is here and clients that require secrets can call self.require_secrets() (in auth.py in that folder). In terms of reading /loading, that's done here and it looks like we do a mkdir-p since it's just a file.
Ok, I see what happens now. Will write a patch for the graceful exit.
Thanks for the help!
That's what I'm here for! :)
Describe the bug
When setting
SREGISTRY_DATABASE
, to a non-existent location,sregistry images
exits with an exception:This problem can be solved easily by running
mkdir -p $SREGISTRY_DATABASE
before executingsregistry images
To Reproduce Steps to reproduce the behavior:
Set
SREGISTRY_DATABASE
to a non-existent directory and executesregistry images
.Expected behavior
IMHO
sregistry
should try creating the folder itself (perhaps withos.makedirs
) before trying to create the new sqlite database file. Only if this fails, an error should be returned.Version of Singularity and Singularity Registry Client