Skip to content

sandbox apply: hide --dry-run (into #362) - #373

Merged
joehorsnell merged 2 commits into
joe/ENG-1187/sandbox-apply-dry-runfrom
davido/ENG-1187/hide-dry-run
Sep 25, 2026
Merged

joehorsnell merged 2 commits into
joe/ENG-1187/sandbox-apply-dry-runfrom
davido/ENG-1187/hide-dry-run

Conversation

@davixcky

Copy link
Copy Markdown
Contributor

Stacked on #362. Merge this into #362's branch, then #362 goes to main as one change.

What

  • --dry-run is registered with MarkHidden. It works exactly as before, but it no longer shows in signadot sandbox apply --help.
  • Removes the Long: description sandbox apply: --dry-run to render a spec without applying it #362 added. That text explained --dry-run=client, so it would have shown in --help even with the flag hidden.
  • TestDryRunIsHidden checks that the flag is registered, hidden, and absent from the usage text.

Why

Agreed in the 24 Sep sync (David and Joe; Scott and Ani had already said hidden-for-now is fine). The sandbox GitHub Action depends on --dry-run=client, and --dry-run=server still needs apiserver support (ENG-1203). Hiding the flag lets the Action ship on a released CLI without making the flag's syntax public yet.

Test plan

  • go test ./internal/command/sandbox/
  • signadot sandbox apply --help does not mention dry-run
  • --dry-run=client still renders (the existing tests still pass)

🤖 Generated with Claude Code

The sandbox GitHub Action depends on --dry-run=client, and
--dry-run=server is still to come (ENG-1203), so the flag keeps working
but stays out of --help and the command's long description until both
are settled.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: low. Approved: this is a narrow help-text change that hides --dry-run while keeping it registered, and no approval policy or present automated-review signal requires human review. Reviewers were not assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

davixcky added a commit that referenced this pull request Sep 25, 2026
…rt as strings (into #374) (#375)

Stacked: #362 ← #373 ← #374 ← this one.

## Why

The template language has no escape for a literal `@{`. So a spec that
`--dry-run` has rendered can't always be rendered again:

```console
$ signadot sandbox apply -f t.yaml --dry-run=client --set 'd=build @{sha} ok' > r.yaml
$ signadot sandbox apply -f r.yaml --dry-run=client
Error: unexpanded variable: sha
```

The sandbox Action renders once, then validates and applies the result.
So any value containing `@{` after the first render failed the step: a
PR title in `description`, an `@{embed: file}` of a Spring config
(`server.url=@{/login}`), or an env value. The Action's correctness
audit rated this high.

## What

- New hidden bool flag `--no-template`: `-f` is decoded as a finished
spec, with no `@{…}` substitution.
- `--set` together with `--no-template` is refused, because there's
nothing to bind.
- Hidden like `--dry-run`, for the same reason: the Action is the only
caller that needs it while the interface settles.

## Also: labels and resource params called `port`

`port2Int` turned every string under a key named `port` into a number,
including inside `spec.labels` and `resources[].params`, whose keys are
the user's own names. So a label or a param called `port` was refused
with `cannot unmarshal number into … params of type string`. It now
skips those two maps, and endpoint ports still convert as before
(`TestPortKeysInFreeFormMapsStayStrings`). Found by the sandbox Action's
re-audit.

## Tests

- `TestNoTemplateReadsARenderedSpecAsItIs`: a value containing `@{sha}`
and `@{embed: x}` renders once, fails to render a second time without
the flag, and with the flag produces byte-identical output.
- `TestNoTemplateRefusesSet`
- `TestNoTemplateIsHidden`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
…run (into #373) (#374)

Stacked: #362 ← #373 (hide the flag) ← this one. Two changes to what
`--dry-run=client` prints.

## 1. Print the decoded sandbox, not the document as read

`--dry-run=client` now prints the sandbox as decoded into
`models.Sandbox`, which is exactly what an apply sends. Before, it
printed the substituted document as it was read.

- Removes `wholeNumbers`. Numbers come from the typed model, so they're
already the right type. The model goes back through JSON with
`UseNumber`, and integers are restored as integers.
- Drops the `null`s the generated models emit for unset lists (`forks`,
`local`, `endpoints`, …).
- Anything the decoder would drop or reject can't appear in the output.

(The first commit, `d594cd2`, accidentally carried only its test.
`14d21ba` is the `apply.go` change it was meant to include.)

## 2. Quote YAML 1.1 lookalikes, a bug in #362

`-f` reads YAML 1.1 (sigs.k8s.io/yaml), but `--dry-run` printed through
goccy, a YAML 1.2 printer that leaves `yes`, `on`, `No`, `y`, `OFF` and
`1e3` unquoted:

```console
$ signadot sandbox apply -f s.yaml --dry-run=client > r.yaml   # env DEBUG='yes'
$ grep value r.yaml
        value: yes
$ signadot sandbox apply -f r.yaml --dry-run=client
Error: couldn't parse YAML sandbox definition - cannot unmarshal bool into Go struct field SandboxEnvVar.forks.customizations.env.value of type string
```

The sandbox Action applies exactly those bytes. So `env: DEBUG=yes`, a
label value like `preview=yes`, or `description: No` failed the apply
*after* validation had passed, and a `dry-run: true` job published a
`rendered-spec` that couldn't be applied. Found by the Action's
correctness audit. The dry-run YAML is now printed with
`sigs.k8s.io/yaml`, the same library `-f` reads with. `--dry-run` never
had a `-o yaml` format of its own, so no other command is affected.

## Evidence

- Output is **byte-identical** to #362 on all 8 sandbox-action golden
fixtures and on its e2e template with real bindings. Multiline strings
still print as `|` blocks.
- New tests:
  - `TestDryRunPrintsOnlyWhatIsSet`
- `TestDryRunQuotesYAML11Lookalikes`: `yes`, `on`, `No`, `1e3`, `1_000`,
`y` and `OFF` come out quoted, and rendering the output again reproduces
it exactly.

## Not fixed here: `@{` in a rendered value

```console
$ signadot sandbox apply -f t.yaml --dry-run=client --set 'd=build @{sha} ok'
  description: build @{sha} ok
$ signadot sandbox apply -f rendered.yaml --dry-run=client
Error: unexpanded variable: sha
```

The template language has no escape for a literal `@{`, and the sandbox
Action renders the document more than once. So any value that contains
`@{` after the first render breaks the next one: a PR title, an
`@{embed: file}` whose file has `@{` in it (for example Spring's
`server.url=@{/login}`), or an env value. Options, to decide separately:
1. Add an escape to the template language (for example `@@{` → literal
`@{`) and escape strings in dry-run output.
2. A hidden flag that skips substitution for a document that's already
rendered. The Action's later passes would use it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@joehorsnell
joehorsnell merged commit ab73448 into joe/ENG-1187/sandbox-apply-dry-run Sep 25, 2026
1 check passed
@joehorsnell
joehorsnell deleted the davido/ENG-1187/hide-dry-run branch September 25, 2026 17:48
scott-cotton pushed a commit that referenced this pull request Oct 1, 2026
Stacked on #362. Merge this into #362's branch, then #362 goes to `main`
as one change.

## What

- `--dry-run` is registered with `MarkHidden`. It works exactly as
before, but it no longer shows in `signadot sandbox apply --help`.
- Removes the `Long:` description #362 added. That text explained
`--dry-run=client`, so it would have shown in `--help` even with the
flag hidden.
- `TestDryRunIsHidden` checks that the flag is registered, hidden, and
absent from the usage text.

## Why

Agreed in the 24 Sep sync (David and Joe; Scott and Ani had already said
hidden-for-now is fine). The sandbox GitHub Action depends on
`--dry-run=client`, and `--dry-run=server` still needs apiserver support
(ENG-1203). Hiding the flag lets the Action ship on a released CLI
without making the flag's syntax public yet.

## Test plan

- [x] `go test ./internal/command/sandbox/`
- [x] `signadot sandbox apply --help` does not mention dry-run
- [x] `--dry-run=client` still renders (the existing tests still pass)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.

2 participants