Skip to content
This repository has been archived by the owner on Nov 9, 2019. It is now read-only.

backends: Use defaults even if config option was provided but empty #191

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

leonklingele
Copy link
Collaborator

This is a workaround for #190

@leonklingele
Copy link
Collaborator Author

leonklingele commented Dec 1, 2018

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:

  1. 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
  1. 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
  1. Default ~/.pick/config.toml with correct syntax & semantic
$ pick ls # will access safe at ~/.pick/pick.safe

$ pick --safe ./test.safe ls # will access safe at $PWD/test.safe
  1. ~/.pick/config.toml with 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
  1. ~/.pick/config.toml with incorrect syntax

An error message will be shown.

@bndw can you please test cases 3. & 4. using the S3 backend?

@bndw
Copy link
Owner

bndw commented Dec 1, 2018

  • 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?

@leonklingele
Copy link
Collaborator Author

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.

@bndw
Copy link
Owner

bndw commented Jan 6, 2019

LGTM with the S3 backend, tested as follows:

  1. Default ~/.pick/config.toml with 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"
  1. Initialized and added an account
$ pick init
...
pick initialized

$ pick add foo
...
Password successfully copied to clipboard
  1. Modified ~/.pick/config.toml to 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"
  1. Initialized the second safe
$ pick init
...
pick initialized

$ pick add bar
...
Password successfully copied to clipboard
  1. And confirmed the --safe override works
› pick --safe tmp/default.safe ls
Enter your master password for safe 's3://bndw-pick/tmp/default.safe'
>
foo

@bndw bndw mentioned this pull request Jan 6, 2019
@bndw
Copy link
Owner

bndw commented Jan 6, 2019

@leonklingele did you have any more tests to add?

@leonklingele
Copy link
Collaborator Author

leonklingele commented Jan 6, 2019 via email

@bndw bndw mentioned this pull request Nov 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants