Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

marshal nested secrets value to string #454

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

iosmanthus
Copy link

This pull request marshals nested secret values according to the format of the secret file.

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@iosmanthus
Copy link
Author

Seem the serialized yaml value has some newline, I should trim the output string.

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@Mic92
Copy link
Owner

Mic92 commented Dec 13, 2023

So the idea is that we can have yaml and json encrypted without having to put them in strings? Would be nice to extend the test case those those as well: https://github.com/Mic92/sops-nix/blob/master/pkgs/sops-install-secrets/nixos-test.nix

The script to update secrets is here: https://github.com/Mic92/sops-nix/blob/master/pkgs/sops-install-secrets/test-assets/sops-edit

@iosmanthus
Copy link
Author

iosmanthus commented Dec 14, 2023

So the idea is that we can have yaml and json encrypted without having to put them in strings? Would be nice to extend the test case those those as well: master/pkgs/sops-install-secrets/nixos-test.nix

The script to update secrets is here: master/pkgs/sops-install-secrets/test-assets/sops-edit

The basic idea is to support any value in a nested secret. However, I found some edge cases for this pull request:

  1. It supports the value of the secret to be a number but shows as a string in the template rendering, I might add some type of information into the placeholder.
  2. If the secret is a string formed by numbers, like "113", the rendered template would be like: ""123"".

I would add some tests to nixos-test.nix, and some unit tests for recurseSecretKey.

@Mic92
Copy link
Owner

Mic92 commented Dec 14, 2023

Maybe it should only render arrays and hashmaps?

Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
@iosmanthus
Copy link
Author

Maybe it should only render arrays and hashmaps?

Perhaps we should marshal nested secrets only in JSON format because it is indent-insensitive. The YAML nested secrets are difficult to fit in the template due to indentation issues.

@kekonn
Copy link

kekonn commented Sep 10, 2024

Is there an ETA on this getting merged? Currently it is blocking me from including a traefik.env file.

@geoffreygarrett
Copy link

+1

@geoffreygarrett
Copy link

Curious how this PR will affect the secrets declaration, I was attempting this before finding this PR:

sops.secrets."cachix-auth-token" = {
    mode = "0400"; 
    key = "'[\"cachix-auth-token\"][\"value\"]'";
};

Which mirrors the CLI extract. I can't tell by this PR diff what this will allow, might be useful to add a test & doc update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants