Skip to content

Use mapstructure to (de-)serialize internal metadata; move metadata processing from specific stores to general place#2120

Open
felixfontein wants to merge 5 commits intogetsops:mainfrom
felixfontein:mapstructure
Open

Use mapstructure to (de-)serialize internal metadata; move metadata processing from specific stores to general place#2120
felixfontein wants to merge 5 commits intogetsops:mainfrom
felixfontein:mapstructure

Conversation

@felixfontein
Copy link
Copy Markdown
Contributor

Right now, metadata is handled quite strangely when flattened (by going through JSON), and all stores somehow have to deal with metadata. This PR cleans this up as follows:

  • Use mapstructure to convert to/from metadata and coerce types.
  • Convert metadata to/from sops.TreeBranch, and provide three options for handling flattening (none; keep sops toplevel map; flatten completely).
  • Properly handle errors during flattening and unflattening. Right now you can panic SOPS and overwrite values by playing around with flattened metadata.
  • Remove old public APIs for dealing with internal metadata and (un-)flattening.

While this is a breaking change, I think this is still OK:

  • The APIs that are broken are internal ones. To from our promise, they're not public and it's not a breaking change.
  • They should only be used by store implementations, which are all part of SOPS itself. This means that even though some other programs use parts of SOPS as a library that aren't public, it is unlikely that they directly use these parts of SOPS that are changed by this PR.

This is related to #1401, #1338, #1046, #1009, which were earlier attempts to introduce mapstructure.

Signed-off-by: Felix Fontein <felix@fontein.de>
Signed-off-by: Felix Fontein <felix@fontein.de>
Signed-off-by: Felix Fontein <felix@fontein.de>
Signed-off-by: Felix Fontein <felix@fontein.de>
Signed-off-by: Felix Fontein <felix@fontein.de>
@felixfontein felixfontein requested a review from a team March 23, 2026 21:52
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.

1 participant