feat(template): offline cy template render command#459
Open
fhacloid wants to merge 3 commits into
Open
Conversation
Render Cycloid stack templates locally with no backend, the missing cornerstone for local stack editing and debugging by humans and agents. The interpolation engine is vendored from youdeploy-http-api under internal/templating/engine (thin adapter: yderr/errtmpl swapped for the stdlib, see VENDORED.md) so offline output is byte-identical to the backend and stays parity-testable. The CLI wrapper adds: - layered context input: component base < context file (JSON/YAML) < stdin/string < --set k=v (highest), with dotted keys and deep-merge - placeholder rendering: unset *known* vars render as <placeholder:$name> instead of erroring, so a template can be exercised without a full platform context; unknown refs warn - multi-template input via --file (repeatable), --dir walk, or stdin; JSON report per template, non-zero exit on any render failure Flags live in internal/cyargs/templating.go; the command is registered in cmd/root.go. Unit tests cover render, layering precedence, and the YAML deep-merge regression; e2e covers the command surface. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`cy template render` is an experimental offline feature — park it under `cy beta template render` until the backend render+context endpoints land. Updates e2e tests, help examples, and changelog entry to match. Includes collateral gci import-sort and alignment fixes on four files touched by `make format`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
cy template render— render Cycloid stack templates locally, with no backend. This is one of the last cornerstones for local stack editing + debugging, for humans and agents alike.How
Engine (vendored). The interpolation engine is copied from
youdeploy-http-apiintointernal/templating/engineas a thin adapter —yderr/errtmplswapped for the stdlib (errors/fmt), everything else byte-identical. Seeengine/VENDORED.mdfor the source commit and the delete-and-import plan for when the CLI merges into the backend. Keeping the engine untouched means offline output stays parity-testable against the backend.CLI wrapper (
internal/templating).--set k=v(highest). Dotted keys nest; maps deep-merge.<placeholder:$name>rather than erroring or rendering empty, so a template can be exercised without a full platform context (this also makes theinventory_jwtguard a no-op offline). Unknown bare references surface as warnings (likely typos).--file/-f(repeatable),--dirwalk, or stdin (-). One JSONReportper template; non-zero exit if any render fails.Wiring. Flags in
internal/cyargs/templating.go; command registered incmd/root.go(template, aliasestpl/tmpl).Tests
internal/templating/*_test.go— render cases (provided/unset-known/unknown/sprig/inventory_jwt/parse-error/nested), context layering precedence,ParseSetdotted keys, and a YAML deep-merge regression (yaml.v3 nested maps defeatedMerge's type assertion → partial--setclobbered siblings; fixed vianormalizeContext).e2e/template_test.go—--set+ placeholder, YAML context-file + dotted override, stdin JSON, parse-error nonzero exit.Build + vet +
golangci-lint --new-from-rev=develop(0 issues) + unit tests all green.Follow-ups (not in this PR)
Backend templating endpoints (render + context-export), a
cy template contextverb that pulls a real component's context, remote mode, and the render-parity test that joins the offline and backend paths.🤖 Generated with Claude Code