-
Notifications
You must be signed in to change notification settings - Fork 155
SOPS can't fine configuration file if it's not in the current working directory #121
Comments
https://github.com/mozilla/sops/#29using-sopsyaml-conf-to-select-kmspgp-for-new-files According to the documentation, sops will search recursively upwards in the directory hierarchy until it finds a .sops.yaml file. It could be that sops is searching upwards from the current working directory, and not upwards from the folder secrets.yaml is in. The documentation isn't clear on that point. |
I'm following the example directory tree from the readme in the plugin GitHub though. Where it looks like it would pick up the yaml file if it is in the same directory or in one upwards. So far it's only picking it up if it is the working directory. Your comment might explain that, but it means the readme in this plugin is not correct or missing information. |
I tested the different scenarios. It looks like sops is searching upwards from the directory of the secrets file (as it should, anything else would have given unpredictable behavior). .sop.yaml in parent directory (current working directory): $ find . -name .sops.yaml
./.sops.yaml
$ cp platform/values.yaml platform/secrets.issue.yaml
$ helm secrets enc platform/secrets.issue.yaml
Encrypting platform/secrets.issue.yaml
Encrypted secrets.issue.yaml .sops.yaml in secret file directory (./platform): $ mv .sops.yaml platform/
$ find . -name .sops.yaml
./platform/.sops.yaml
$ cp platform/values.yaml platform/secrets.issue.yaml
$ helm secrets enc platform/secrets.issue.yaml
Encrypting platform/secrets.issue.yaml
Encrypted secrets.issue.yaml .sops.yaml in other sibling directory (./yaml): $ mv platform/.sops.yaml yaml/
$ find . -name .sops.yaml
./yaml/.sops.yaml
$ cp platform/values.yaml platform/secrets.issue.yaml
$ helm secrets enc platform/secrets.issue.yaml
Encrypting platform/secrets.issue.yaml
config file not found and no keys provided through command line options
Error: plugin "secrets" exited with error So for me it works as expected. Could something else be causing the problem you're having? |
The first and third works like my install, the second doesn't. Maybe a different version of sops? I'm using 3.3.0 |
Or a different version of helm:
For the rest there isn't much special, it's a clean project I started the other day. |
This is a regression that was introduced in So if you have
|
I changed my project structure a bit due some other issues with Helm, which solves this issue for me as a side effect. But the bug will probably affect others as well |
I believe this is a regression caused by #117. The original encrypt_helper would cd to the directory before running sops (https://github.com/futuresimple/helm-secrets/pull/117/files#diff-60baae393acfb88c61e9d2e0d7eea239L249), now it doesn't. |
When I did my testing above I got a bit confused regarding the default sops behavior. Sops actually does search for the config file to use starting from the current working directory and upwards: $ mv .sops.yaml platform/
$ cp platform/values.yaml platform/secrets.foo.yaml
$ sops -e -i platform/secrets.foo.yaml
config file not found and no keys provided through command line options
$ (cd platform; sops -e -i secrets.foo.yaml) The original version 1.3.1 code did its own search for the sops config file, starting from the current working directory and downwards, until it found the one nearest the secrets file. Then it set the config file explicitly on the sops command line. (This approach assumes that the secrets file is in a subdir of the cwd, and also that the config file is not above the cwd.) When I rewrote the function I simplified this by doing a "cd" to the secret file's directory and letting sops find the closest config file above. This seems like the correct thing to do, to me. For some reason this has been changed now by issue #92 and PR #117. I think the usage of Update: I think sops 3.3.1 has changed the path_regex behavior so that it fixes the problem in #92. If so #117 was not needed and should be reverted. |
I still have the issue above with these versions: $ sops --version $ helm version $ helm plugin list |
I have published You should be able to do: |
If I put the .sops.yaml file in any other directory then the current working directory, like suggested in the README.md, sops won't pick it up. It will give the following error:
config file not found and no keys provided through command line options
. Are the docs incorrect, or am I missing something, e.g.:The text was updated successfully, but these errors were encountered: