pick
pick copied to clipboard
backends: Use defaults even if config option was provided but empty
This is a workaround for #190
Feel free to merge, otherwise I'll provide some tests in this PR (which might take some time though).
This PR was tested using the following configurations:
- Missing
~/.pick/config.toml
$ pick ls # will access safe at ~/.pick/pick.safe
$ pick --safe ./test.safe ls # will access safe at $PWD/test.safe
- Empty
~/.pick/config.toml
$ pick ls # will access safe at ~/.pick/pick.safe
$ pick --safe ./test.safe ls # will access safe at $PWD/test.safe
- Default
~/.pick/config.tomlwith correct syntax & semantic
$ pick ls # will access safe at ~/.pick/pick.safe
$ pick --safe ./test.safe ls # will access safe at $PWD/test.safe
~/.pick/config.tomlwith correct syntax & semantic and custom file path
$ pick ls # will access safe at the configured file backend path
$ pick --safe ./test.safe ls # will access safe at $PWD/test.safe
~/.pick/config.tomlwith incorrect syntax
An error message will be shown.
@bndw can you please test cases 3. & 4. using the S3 backend?
- I'll test those configurations against S3 this weekend
- Let's get tests in before considering the merge
- @leonklingele thoughts on writing a config file on
pick init?
thoughts on writing a config file on
pick init
That'd be nice! Probably worth adding a --config flag to the init command to support installing a config file after the fact. The example config (config.toml.in) could be embedded into the binary using for example statik.
LGTM with the S3 backend, tested as follows:
- Default
~/.pick/config.tomlwith the S3 backend pointed to a non-existent safe file
[storage]
type = "s3"
[storage.settings]
profile = "personal"
region = "us-west-2"
bucket = "bndw-pick"
key = "tmp/default.safe"
- Initialized and added an account
$ pick init
...
pick initialized
$ pick add foo
...
Password successfully copied to clipboard
- Modified
~/.pick/config.tomlto use a second, new safe file
[storage]
type = "s3"
[storage.settings]
profile = "personal"
region = "us-west-2"
bucket = "bndw-pick"
key = "tmp/default_two.safe"
- Initialized the second safe
$ pick init
...
pick initialized
$ pick add bar
...
Password successfully copied to clipboard
- And confirmed the
--safeoverride works
› pick --safe tmp/default.safe ls
Enter your master password for safe 's3://bndw-pick/tmp/default.safe'
>
foo
@leonklingele did you have any more tests to add?
Whoops, totally forgot about them. I hope to find some time by the end of next week and will update this PR.