fix(cli): make Enter skip resource-creating configure-gcp steps by cristim · Pull Request #2249 · LeanerCloud/cloud-commitments-cli · GitHub
Skip to content

fix(cli): make Enter skip resource-creating configure-gcp steps - #2249

Merged
cristim merged 1 commit into
mainfrom
fix/gcp-wizard-enter-skips
Oct 16, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/gcp-wizard-enter-skips

Conversation

@cristim

@cristim cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member

Refs #1613. This covers the GCP half of finding A10-030. The Azure half (cmd/configure_azure.go) follows after the open #2212 lands, since that PR touches the same file.

Summary

In the configure-gcp wizard, pressing Enter at a [R]un, [S]kip? prompt ran the step: it created the service account, granted roles, minted a key, or ran gcloud auth login / ADC login. A stray Enter therefore made real changes to cloud identities.

  • Enter now skips at all four prompts. "" moved from the run case to the skip case at each one:
    • create service account
    • grant roles
    • create key
    • promptAndRunGCPCommand, which handles auth and ADC login
  • The prompts show the default: [r]un, [S]kip (default)?. Enter prints the step's normal skip message rather than "Unknown option". Unknown input already skipped, so its behaviour is unchanged.
  • Login steps also default to skip. They affect identity, and if they are skipped by mistake, the next SDK step fails loudly on missing ADC.
  • docs/cli/cloud-setup.md and CHANGELOG.md describe the new default.
  • The configure_gcp_iam_test.go "empty" scenario asserted the old Enter-runs behaviour, so it is removed. It was otherwise identical to the "create" scenario. The wizard-driving fixtures already send an explicit r.

Evidence (local, macOS, GOTOOLCHAIN=go1.26.9, stubbed Google API, no GCP calls)

  • Fail before / pass after: the new cmd/configure_gcp_default_skip_test.go drives "", r and s through all four steps.
    • With origin/main's configure_gcp.go, the four empty-input cases fail.
    • With the fix, they pass, and the test asserts the skip message and no "Unknown option".
  • Mutation probes: putting "" back on the run case fails create-key/empty and TestPromptAndRunGCPCommand_DefaultIsSkip.
  • Checks:
    • make build passes.
    • go vet ./... passes.
    • go test -race ./cmd/ passes (1568) on the rebased tree.
    • The GCP tests pass with -count=3 -race.
    • golangci-lint v2.10.1 reports 0 issues.
    • scripts/test-git-secrets-allowlist.sh passes 44/44.
  • Review: an independent non-author reviewer (sonnet, high) did two passes.
    • It judged the login-step default.
    • It confirmed that no "" run-defaults remain in configure_gcp.go and that no coverage was lost.
    • Its one nit, the misleading "Unknown option" text on Enter, is applied.

🤖 Generated with Claude Code

Empty input at the [R]un/[S]kip prompts ran the step, creating the service
account, granting roles and minting a key. Empty input now skips; only r or
run executes. Prompts read "[r]un, [S]kip (default)?". The gcloud auth login
prompt follows the same rule. Unknown input already skipped.

The "empty" IAM fixture scenario is removed (it asserted Enter runs); table
tests cover "", r and s for every step against a stubbed Google API.

Refs #1613

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cristim cristim added priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/internal Team-internal only effort/l Weeks type/chore Maintenance / non-user-visible triaged Item has been triaged labels Oct 16, 2026
@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Independent review verdict: CLEAN at ec929b0

Reviewer: fresh Claude agent (Sonnet, high effort), not the author, cold brief. The PR body was treated as a claim. Coordinator: claude-cc-reviewer.

Blocking findings: none. No step that creates or changes a resource still runs on Enter.

Prompt (cmd/configure_gcp.go) Creates or changes Enter: before → after
gcloud auth login :734 (via promptAndRunGCPCommand :1013) local identity only run → skip
ADC login :745 local identity only run → skip
Create service account :805 SA run → skip, then asks for an existing SA email
Grant roles :900 custom role and IAM policy run → skip
Create key :947 SA key run → skip
Project listing :765 (shared promptRunOrSkipListing) read-only run (unchanged)
"Continue anyway?" :1058 already N

Non-interactive input:

  • The CLI has no --yes or --non-interactive flag.
  • EOF on empty input errors out of ReadString/readTrimmedLine and aborts the wizard; it is never read as yes.
  • Piped bare Enters now skip each step with "Skipping …", and a later step fails loudly. Nothing is skipped silently.

Prompt text, CHANGELOG and docs:

  • All four changed prompts read [r]un, [S]kip (default)?, which matches the code.
  • The CHANGELOG and docs/cli/cloud-setup.md are accurate.

Notes (non-blocking):

  • The two login steps also flip to skip-by-default. They touch only local identity, not cloud resources.
  • The "Skipping …" message could say how to run the step manually.

What was attacked and how (no GCP calls):

  • go vet ./cmd/... is clean. go test -race -count=1 ./cmd/... passes 1568.
  • Fail-before: with main's configure_gcp.go, the create-service-account, grant-roles and create-key /empty cases fail, and so does TestPromptAndRunGCPCommand_DefaultIsSkip/empty.
  • Mutation probe: restoring the empty default to "run" on grant-roles fails grant-roles/empty. A second probe was a no-op because of BSD sed, so it proves nothing.

Gate: no closing issue, and the PR carries its own triage labels. Merge once CI is green and the CodeRabbit gate is met.

@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

@cristim
cristim merged commit 1306c4d into main Oct 16, 2026
12 checks passed
@cristim
cristim deleted the fix/gcp-wizard-enter-skips branch October 16, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/l Weeks impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant