Implement support for JSON Pointer (RFC 6901) in "sops --set"
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.1k
- Forks
- 1.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 9
Description
sops --set uses a json encoded string to identify which key/value to write/change.
This json encoded string is used when modifying json files or yaml files.
Some struture-aware diff tools create "patch files" that contain JSON Pointer to reference the value that should be added, deleted or changed. One tool of that kind: https://github.com/swaggest/json-diff
Example patch file content (where "path" is the JSON Pointer):
[
{"value":4,"op":"test","path":"/key1/0"},
{"value":5,"op":"replace","path":"/key1/0"},
{"op":"remove","path":"/key2"},
{"op":"remove","path":"/key3/sub0"},
{"value":"a","op":"test","path":"/key3/sub1"},
{"value":"c","op":"replace","path":"/key3/sub1"},
{"value":"b","op":"test","path":"/key3/sub2"},
{"value":false,"op":"replace","path":"/key3/sub2"},
{"value":0,"op":"add","path":"/key3/sub3"},
{"value":true,"op":"add","path":"/key4/0/subs/2/add"},
{"op":"remove","path":"/key4/1/b"},
{"value":false,"op":"add","path":"/key4/1/c"},
{"value":1,"op":"add","path":"/key4/2/c"},
{"value":"wat","op":"add","path":"/key5"}
]
To apply such a patch value-by-value via sops --set '' it is cumbersom to convert a JSON Pointer to a --set-compatible json encoded string. Please add support for JSON Pointer.
Instead of:
sops --set '["key3"][sub0] true'
it should be possible to write:
sops --setPointer '/key3/sub0 true'
This feature would help to implement a "sops auto merge conflict resolver".
https://github.com/mozilla/sops/issues/52
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the CLI handling for sops --set and trace how its JSON-encoded paths are parsed and applied. Compare that behavior with RFC 6901 paths, using the examples in the issue as cases; done means sops --setPointer '/key3/sub0 true' and equivalent pointer paths can update JSON and YAML values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100