fix a bug where not having a config results in a panic #1371
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you execute sops without a config file, you'll get a lovely panic:
This problem was introduced by e9e2346. This commit changed the signature of common.storeConstructor from
to
All of the storeConstructor functions attempt to dereference the StoresConfig pointer, which causes a panic if it's nil.
inputStore and outputStore both use the following function to load a StoresConfig:
If loadStoresConfig cannot find a config file, it returns
nil, err
. inputStore ignores the error from loadStoresConfig and invokes common.DefaultStoreForPathOrFormat(nil) which eventually invokes a storeConstructor with a nil pointer.The comment in loadStoresConfig says config files aren't necessary so to fix this we just construct a new StoresConfig if we can't find a config file.
This issue doesn't show up if you run sops in the git repo, since there's always a .sops.yaml for demonstration purposes. Without that file, sops will panic.