Skip to content

Add environment fork / deploy / decommission, instance copy/promote#238

Merged
coryodaniel merged 6 commits into
mainfrom
env-commands
May 18, 2026
Merged

Add environment fork / deploy / decommission, instance copy/promote#238
coryodaniel merged 6 commits into
mainfrom
env-commands

Conversation

@coryodaniel
Copy link
Copy Markdown
Member

@coryodaniel coryodaniel commented May 15, 2026

Summary

Four CLI wrappers around the V2 primitives the preview command already composes — useful on their own when you want to drive a fork, a promote, a deploy, or a teardown without a YAML config.

Command API Notes
mass environment fork <parent> <new-id> forkEnvironment --copy-environment-defaults, --copy-secrets, --copy-remote-references, plus the usual --name / --description / --attributes. Idempotent re-fork against the same parent.
mass environment deploy <env> deployEnvironment Fans a provision wave across every instance in dependency order. Cancels any in-flight env deployment. --follow streams interleaved per-instance logs, padded so the prefix column stays aligned.
mass environment decommission <env> decommissionEnvironment Reverse-order teardown across every instance. --follow same as deploy. Blocked when decommissionProtection is on. Env shell stays; chain with mass environment delete to remove the empty env.
mass instance copy <src> --to <dst> (alias promote) copyInstance --overrides <path> (JSON/YAML deep-merged), --copy-secrets, --copy-remote-references. Components must match; destination ends up with a plan deployment for review.

Helpdocs, generated docs, and unit tests included. SDK pinned at v0.2.4.

Test plan

  • go build ./...
  • make test (per repo convention)
  • golangci-lint clean (funlen exemptions handled by extracting per-command builders)
  • Smoke against a real org after merge — fork, deploy --follow, decommission --follow, delete

🤖 Generated with Claude Code

@coryodaniel coryodaniel force-pushed the env-commands branch 2 times, most recently from 200ab04 to 6f8b795 Compare May 15, 2026 23:58
Base automatically changed from preview-cli to main May 16, 2026 00:02
coryodaniel and others added 4 commits May 15, 2026 17:04
…`promote`)

Three thin wrappers around SDK primitives that the preview command
already composes:

- `mass environment fork <parent> <new-ID>` — exposes
  Environments.Fork with --copy-environment-defaults, --copy-secrets,
  --copy-remote-references, and --attributes. Idempotent against the
  same parent.
- `mass environment deploy <env>` — exposes Environments.Deploy;
  cancels any in-flight environment deployment and schedules a fresh
  provision wave.
- `mass instance copy <source> <destination>` (alias `promote`) —
  exposes Instances.Copy with --overrides (path to JSON/YAML),
  --copy-secrets, --copy-remote-references, and --message. Components
  must match.

Helpdocs and generated docs included.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reuses the FollowEnvironment helper landed with the preview --follow
flag. Behavior is identical: tail every deployment's logs, prefix each
line with the instance id, exit once the rollout reaches a quiet
steady state.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`mass instance promote ecomm-staging-db ecomm-production-db` reads
ambiguously — easy to land on the wrong side at the end of a long
day. Promote (and copy) now take the destination through a required
`--to` flag:

    mass instance promote ecomm-staging-db --to ecomm-production-db

Same for copy. Helpdoc and generated docs follow the new shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CopyInstanceInput.Message was removed from the V2 schema — copy is
pure config staging, not deployment. SDK v0.2.2 dropped Message from
the public CopyInput type. Drop the corresponding CLI flag and update
the helpdoc to point users at `mass instance deploy` for the
follow-up deployment.
coryodaniel and others added 2 commits May 15, 2026 17:09
NewCmdEnvironment was 110 lines and NewCmdInstance was 111 lines after
the new commands landed (preview/fork/deploy on environment; copy on
instance) — over golangci-lint's 100-line funlen cap. Each new command's
construction now lives in its own `new*Cmd` builder; the parents just
AddCommand them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Wires the new V2 `decommissionEnvironment` mutation (platform PR #3259)
through `Environments.Decommission` (SDK v0.2.4) so a fan-out teardown is
a single CLI call. Mirrors `environment deploy`:

- Reverse-dependency-order tear-down across every instance.
- `--follow` streams interleaved per-instance logs.
- Async — returns once the wave is enqueued.

The environment shell stays put; run `mass environment delete` after to
remove the empty environment. Decommissioning is rejected when
`decommissionProtection` is on; disable via `updateEnvironment` first.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coryodaniel coryodaniel changed the title Add environment fork, environment deploy, instance copy / promote Add environment fork / deploy / decommission, instance copy/promote May 18, 2026
@coryodaniel coryodaniel merged commit 9c2bf06 into main May 18, 2026
5 checks passed
@coryodaniel coryodaniel deleted the env-commands branch May 18, 2026 19:24
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