JSON to elmer keys
Turn a JSON object into elmer key set, key get or dep key commands
Command
write into a local values file (elmer-configuration, elmer-core, an artifact)
Shape of the output
Every leaf of the JSON becomes its own command, so only the keys you pasted are touched.
The key the pasted JSON hangs off. Leave empty for the root of the values file.
Arrays
elmer cannot address an array element by path, and refuses to append one array to another. Setting the array whole replaces every element; appending per element is the only way to add to what is there, and on an object element -k is what tells an update apart from a new entry.
Comments and trailing commas are stripped before parsing, so text copied straight out of a values file works.
bash
Paste JSON above to see it as elmer key set commandsWhat this tool does and does not do
- Nothing runs and nothing is contacted. This is a text-to-text conversion like the rest of the site: the script is for you to read, then run yourself, in a checkout you can revert.
- Paths are dot-separated with no escape syntax, and elmer only walks objects when resolving them. An array is therefore always a leaf — set whole, or appended to one element at a time — and a JSON key containing a dot cannot be addressed at all.
- `elmer key` writes the values file in the current directory (values.json / default.values.json / artifact.values.json and the matching .d directory, in that order). Run the script from that directory, or add -C <dir> or -b <file> yourself.
- `elmer dep key set` commits and pushes to the deployment's repositories unless --skip-commit is passed, and it takes the deployment lock. It does not apply anything.
- One command per key means one file rewrite per key, so a long script is not atomic: if command 30 fails, the first 29 have already been written.
- Duplicate keys in the pasted JSON are resolved the way JSON.parse resolves them — last one wins, silently. Deduplicate before pasting if that matters.