sandbox apply: --dry-run to render a spec without applying it - #362
Open
joehorsnell wants to merge 1 commit into
Open
sandbox apply: --dry-run to render a spec without applying it#362joehorsnell wants to merge 1 commit into
joehorsnell wants to merge 1 commit into
Conversation
Getting the spec a template renders to meant applying the sandbox, so CI had no way to show what it was about to do and no way to check a template without creating something. Rendering already happens locally; it just ran after authentication, so this moves it before and prints the result. The output is a spec rather than a report, so it can be diffed and passed straight back to -f. A test pins that, since a caller that renders in one step and applies in another depends on it. Co-authored-by: Cursor <cursoragent@cursor.com>
5 tasks
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 this does
Adds
--dry-run=none|client|servertosignadot sandbox apply.clientrenders thespec, validates it, and prints it instead of applying it:
Why
Rendering a template has always been local, but the only way to see what it produced
was to apply the sandbox. That leaves two things unserved: CI cannot show what it is
about to do, and a template cannot be checked without creating something.
The rendering step already existed and already ran locally — it just ran after
authentication. Moving it before authentication is most of this change, and it means
--dry-run=clientworks for someone who has never logged in, and fails identicallywhether or not they have.
The output is a spec, not a report, so it can be reviewed, diffed, and passed straight
back to
-f.TestDryRunOutputIsAFixedPointpins that: re-rendering a rendered specchanges nothing. That property is what lets a caller render in one step and apply
exactly those bytes in another, which is how the sandbox GitHub Action
(ENG-1187)
gets a
rendered-specoutput that is provably what was applied.--dry-run=serveris accepted by the flag and rejected at runtime, since it needs avalidateOnlyparameter on the apiserver that does not exist yet(ENG-1203).
Keeping it in the grammar now means adding it later needs no new spelling, and the
distinction between rendering locally and asking the server to validate is the one
kubectlusers already know.Scope
Deliberately small and self-contained. It is the first of two: the larger change on
#361 proposes a values document and a
built-in template so a sandbox can be described without authoring a template at all.
That one is a design decision and is still a draft. This one stands on its own for
anyone who already has a template.
One behaviour change beyond the new flag: the "sandbox spec must specify cluster" check
now happens before authentication rather than after, so a spec missing a cluster reports
that instead of an auth failure. Existing valid invocations are unaffected.
Test plan
go test ./internal/...--dry-run=clientrenders--setsubstitutions and never builds an API client,so it cannot be reaching the network
unexpanded
@{var}--dry-run=serveris rejected with a message pointing at the follow-upapply -f <your template> --dry-run=clientagainst a realtemplate, with and without being logged in