-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: add TOML store #2031
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
base: main
Are you sure you want to change the base?
feat: add TOML store #2031
Conversation
Signed-off-by: João Fernandes <[email protected]>
Signed-off-by: João Fernandes <[email protected]>
Signed-off-by: João Fernandes <[email protected]>
Signed-off-by: João Fernandes <[email protected]>
Signed-off-by: João Fernandes <[email protected]>
e3b5072 to
d0bf7b4
Compare
d0bf7b4 to
39cd216
Compare
felixfontein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this up! It would be great if this store could also handle comments, but it seems the library doesn't really handle them yet.
|
|
||
| // Sort each group independently. | ||
| sortKeysNaturally(simpleKeys) | ||
| sortKeysNaturally(complexKeys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is a good idea to sort keys. I as a SOPS user expect a store to not modify the key order.
| // mapToTreeBranch converts a map[string]any to a sops.TreeBranch. | ||
| func mapToTreeBranch(m map[string]any) (sops.TreeBranch, error) { | ||
| // Separate keys by type: simple values first, then complex types | ||
| // (tables/arrays). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the rationale for this?
| } | ||
|
|
||
| // Replace single quotes with double quotes for string values. | ||
| result := bytes.ReplaceAll(buf.Bytes(), []byte("'"), []byte("\"")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this?
|
|
||
| [2] | ||
| 21 = [21.1, 21.2] | ||
| 22 = 22 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make the indentation configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, no, when using the "normal" API. Please check #2031 (comment) - it might be possible if I go for a different approach.
Happy to contribute! I have good and bad news: the good news is that, to some extent, it's possible to handle comments. Being specific, it's possible to handle start-of-the-line comments, but not end-of-the-line comments, i.e., # We can handle these
xpto = 42 # But we can't handle theseThe bad news is that this requires using the unstable API and results in significantly more complex code. Should I give it a try? |
|
Hmm, good question... Do you know whether the marshaller supports comments (at least start-of-line ones) as well? If it does not, then I guess it doesn't make sense - yet - to support them. |
The marshaler, i.e., the "normal" |
|
I can only see parsing code in the unstable API. Can you point me to the unstable API that allows creating TOML files with start-of-the-line comments? |
Fixes #369. Supersedes #812 (that in turn superseded #533). Hopefully, the third time's the charm.
Uses
github.com/pelletier/go-toml/v2. It discards comments.