Skip to content

feat: add --vars-file flag for layered input variables#227

Merged
josegonzalez merged 2 commits intomainfrom
207-add-vars-file-flag-for-layered-input-variables
Apr 29, 2026
Merged

feat: add --vars-file flag for layered input variables#227
josegonzalez merged 2 commits intomainfrom
207-add-vars-file-flag-for-layered-input-variables

Conversation

@josegonzalez
Copy link
Copy Markdown
Member

@josegonzalez josegonzalez commented Apr 29, 2026

Adds a repeatable --vars-file <path> flag to apply, plan, and validate for loading input values from external YAML or JSON files. Precedence runs from file-level inputs: defaults at the bottom up to --name=value CLI flags at the top, with --vars-file slotting in between defaults and CLI flags. Multiple --vars-file arguments merge left-to-right so later files override earlier ones, unknown keys error with a Levenshtein-based suggestion against the declared input names, and values are coerced to the input's declared type so JSON numbers and YAML bools land correctly without per-call branching downstream.

Also includes a small drive-by fix for the docket fmt is a no-op on already-canonical input (mtime preserved) bats test. The previous stat -f "%m" tasks.yml 2>/dev/null || stat -c "%Y" tasks.yml ordering ran the macOS form first, but on Linux -f switches stat to filesystem-info mode and produces non-mtime output that varies between calls, so the captured mtime values differed whenever disk usage shifted during the 1s sleep. Reversing the order keeps Linux on the cleanly-succeeding GNU branch and only falls back on macOS.

Closes #207.

Adds a repeatable `--vars-file <path>` flag to `apply`, `plan`, and `validate` for loading input values from external YAML or JSON files. Precedence runs from file-level `inputs:` defaults at the bottom up to `--name=value` CLI flags at the top, with `--vars-file` slotting in between defaults and CLI flags. Multiple `--vars-file` arguments merge left-to-right so later files override earlier ones, unknown keys error with a Levenshtein-based suggestion against the declared input names, and values are coerced to the input's declared type so JSON numbers and YAML bools land correctly without per-call branching downstream.
`stat -f "%m" tasks.yml` partially succeeds on Linux because `-f` switches stat to filesystem-info mode and `tasks.yml` is treated as a valid filesystem to inspect, leaving extraneous block-free output in the captured variable. The previous fallback order ran the macOS form first, so on Linux both `before_mtime` and `after_mtime` carried that varying filesystem info and the equality check failed whenever disk usage shifted during the 1s sleep. Running the GNU `-c "%Y"` form first keeps Linux on the cleanly-succeeding branch and only falls back on macOS where `-c` is unsupported.
@josegonzalez josegonzalez merged commit 33e82ab into main Apr 29, 2026
10 checks passed
@josegonzalez josegonzalez deleted the 207-add-vars-file-flag-for-layered-input-variables branch April 29, 2026 05:50
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.

Add --vars-file flag for layered input variables

1 participant