Decrypt declared sops files before rendering template #118
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.
Hi, I noticed that currently, sops files are only applied to secrets. To provide encrypted env vars, we can use sops encrypted
.envfile, but that only applies toenvironmentsection, and doesn't behave like docker compose, where you can use the value from an.envfile in the whole compose file.I noticed in the code that there is a stage to render the template before using it as a stack file. But the values file cannot be encrypted. So I made a few changes to first decrypt the declared sops files, which will include the values file for rendering the template. Then we render the template using the decrypted values file, and finally discover sops file and decrypt them before deploying the stack.
The modified version has been tested and used in my workflow, and it works as intended:
And if you want to test, the image is
hurui200320/swarm-cd:1.7.1-sops