Skip to content

[local-test-only] Add switchover pair/endpoint commands#3399

Open
Ethan Wang (wyuzheng) wants to merge 9 commits into
mainfrom
switchover-cli-local-demo
Open

[local-test-only] Add switchover pair/endpoint commands#3399
Ethan Wang (wyuzheng) wants to merge 9 commits into
mainfrom
switchover-cli-local-demo

Conversation

@wyuzheng

Copy link
Copy Markdown

Summary

  • Adds a confluent switchover pair/confluent switchover endpoint command group for local demo/testing purposes only.
  • Wires the already-merged ccloud-sdk-go-v2-internal/switchover SDK (pinned to master commit 4e3e503e) into pkg/ccloudv2 and new internal/switchover/{pair,endpoint} packages.
  • Scoped to create/describe/update/trigger-switch for pairs and create/describe/update/activate for endpoints — list/delete omitted since cc-switchover's backend doesn't implement those RPCs yet.

Related

Test plan

  • go build ./... and go vet clean
  • make build succeeds locally
  • confluent switchover pair/endpoint <subcommand> --help renders expected flags
  • Not tested against a live backend (no login in this environment)

🤖 Generated with Claude Code

Wires the ccloud-sdk-go-v2-internal/switchover SDK into a new confluent
switchover pair/endpoint command group, for local demo purposes only.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@wyuzheng
Ethan Wang (wyuzheng) requested a review from a team as a code owner July 8, 2026 21:04
Copilot AI review requested due to automatic review settings July 8, 2026 21:04
@confluent-cla-assistant

Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Copilot AI 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.

Pull request overview

Adds a new confluent switchover command group (pairs + endpoints) and wires it into the CLI’s CCloud v2 client layer using the internal Switchover SDK, primarily for local/demo usage.

Changes:

  • Introduces internal/switchover Cobra command tree with pair and endpoint subcommands (create/describe/update + trigger-switch/activate actions).
  • Adds pkg/ccloudv2 client wiring for the Switchover API (new client + wrapper methods).
  • Adds the ccloud-sdk-go-v2-internal/switchover dependency in go.mod/go.sum.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/ccloudv2/switchover.go Adds Switchover API client construction + thin wrapper methods on ccloudv2.Client.
pkg/ccloudv2/client.go Registers SwitchoverClient on the shared v2 client and initializes it in NewClient.
internal/switchover/command.go Adds the top-level switchover command group and attaches pair/endpoint subcommands.
internal/switchover/pair/command.go Defines switchover pair command group and output struct.
internal/switchover/pair/command_create.go Implements switchover pair create and --member flag parsing/printing.
internal/switchover/pair/command_describe.go Implements switchover pair describe with environment scoping.
internal/switchover/pair/command_update.go Implements switchover pair update (display-name only).
internal/switchover/pair/command_trigger_switch.go Implements switchover pair trigger-switch with confirmation prompt.
internal/switchover/endpoint/command.go Defines switchover endpoint command group and output struct.
internal/switchover/endpoint/command_create.go Implements switchover endpoint create and --endpoint flag parsing/printing.
internal/switchover/endpoint/command_describe.go Implements switchover endpoint describe with environment scoping.
internal/switchover/endpoint/command_update.go Implements switchover endpoint update (display-name only).
internal/switchover/endpoint/command_activate.go Implements switchover endpoint activate.
internal/command.go Registers the new top-level switchover command with the root CLI command.
go.mod Adds the internal Switchover SDK module requirement.
go.sum Adds checksums for the internal Switchover SDK module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/command.go
cmd.AddCommand(servicequota.New(prerunner))
cmd.AddCommand(shell.New(cmd, func() *cobra.Command { return NewConfluentCommand(cfg) }))
cmd.AddCommand(streamshare.New(prerunner))
cmd.AddCommand(switchover.New(prerunner))
Comment on lines +11 to +16
func New(prerunner pcmd.PreRunner) *cobra.Command {
cmd := &cobra.Command{
Use: "switchover",
Short: "Manage Kafka disaster recovery switchover pairs and endpoints.",
Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireNonAPIKeyCloudLogin},
}
Ethan Wang (wyuzheng) and others added 8 commits July 8, 2026 14:28
Documents how to build and use the switchover CLI commands from this
branch, for local demo/sharing purposes only.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Pins ccloud-sdk-go-v2-internal/switchover to PR #832's commit (spec sync
fixes: phase enum ERROR->FAILED, dr_endpoint removed, switchover_pair
flattened to switchover_pair_id, EndpointFilter resource_id/cloud/region
removed).

Updates internal/switchover/endpoint/command_create.go and command.go to
match: drop resource-id/cloud/region from the --endpoint flag, use the
flat SwitchoverPairId field, remove the DrEndpoint output column.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The stag Switchover Early Access gate only applies to the bearer/login
path, not Cloud API keys — add a CONFLUENT_CLOUD_API_KEY /
CONFLUENT_CLOUD_API_SECRET escape hatch to switchoverApiContext for
local demo/testing against staging orgs without EA granted yet, and
document it in the README.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Bumps ccloud-sdk-go-v2-internal/switchover to v0.0.0-20260716234419-9fed8981fa8c
(regenerated from confluentinc/api#2545) and migrates the switchover commands
to the updated API surface:

- Pair/Endpoint update now send the dedicated SwitchoverV1Switchover{Pair,
  Endpoint}UpdateRequest bodies.
- Spec.Environment changed from EnvScopedObjectReference to a flat env-id
  string across create/print paths.
- Pair failover request is now nested under Spec and carries the required
  environment in the body; trigger-switch gained an --environment flag.
- EndpointFilter.Gateway was renamed to NetworkId; the --endpoint "gateway="
  key is now "network=".
- Removed `endpoint activate`: the Activate operation was dropped from the API.

Also merges origin/main to keep the branch in sync.

Validation:
- go build ./... clean
- make build (goreleaser) produces a working binary; `switchover` command tree
  verified (activate gone, trigger-switch has --environment).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The switchover update operations require the `environment` query parameter
(required: true in the OpenAPI spec), but the pair/endpoint update commands
neither exposed `--environment` nor forwarded it, so `confluent switchover
pair update` / `endpoint update` would fail against a live backend.

Add the shared `--environment` flag to both update commands and thread the
resolved environment id through the UpdateSwitchoverPair/UpdateSwitchoverEndpoint
client wrappers via `.Environment(...)`, matching the get/failover paths and
the auth/context design (env is explicit; org implicit from the credential).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wire `switchover pair list`/`pair delete` and `switchover endpoint
list`/`endpoint delete`, matching the switchover API surface. Adds
List*/Delete* wrappers in pkg/ccloudv2/switchover.go (token-based
pagination) and SwitchoverPair/SwitchoverEndpoint resource constants.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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