yqr Demo
A runnable showcase of yqr, a jq-style query & transform tool for YAML.
Run it
bash yqr-demo.sh
The script needs yqr on your PATH. It resolves its own directory, so it
works from any working directory and reads the sample files in place.
What’s in here
| File | Role |
|---|---|
yqr-demo.sh | The narrated walkthrough (eight sections, each a real command). Linked on GitHub – accent does not serve script files as page media. |
deploy.yaml | A Kubernetes Deployment – the input for navigation & iteration. |
config.yaml | A hand-commented config – the input for the fidelity engine. |
What it shows
- Navigate nested structure – dotted paths and array indexing (
.spec.containers[0].image, negative indices). - Iterate collections –
[]streams every element. - Compose with pipes –
|feeds one filter into the next. - Raw output –
-rdrops YAML quoting for shell scripting. - Reads from stdin – pipe YAML straight in.
- Fidelity by default –
yqr '.'reproduces the input byte-for-byte, comments and all, with no flag.--normalizeopts into the classic re-serializing pipeline. - jq-style exit codes –
3for parse errors,5for runtime errors, for scriptable error handling. - Validate after editing –
yqr validateedits a copy in place, then confirms the file is still correct YAML (silent, exit 0). Break it and the verdict is a compiler-style diagnostic with a stable code, the offending line, and a caret;--strictadditionally catches a duplicate key, which ordinary reads accept silently.