Skip to content

[ORC-10127] Add switchover CLI commands (pair, endpoint)#3382

Draft
Ethan Wang (wyuzheng) wants to merge 1 commit into
mainfrom
ORC-10127-add-switchover-commands
Draft

[ORC-10127] Add switchover CLI commands (pair, endpoint)#3382
Ethan Wang (wyuzheng) wants to merge 1 commit into
mainfrom
ORC-10127-add-switchover-commands

Conversation

@wyuzheng

Copy link
Copy Markdown

Summary

Adds confluent switchover CLI commands for the Kafka DR Switchover API (ORC-10127 of ORC-9794):

  • confluent switchover paircreate / list / describe / update / delete / failover
  • confluent switchover endpointcreate / list / describe / update / delete / activate

Plus the ccloudv2 SDK wrapper, output structs, resource constants, command + client registration,
and test-server mock handlers.

Why hand-written (not cli-terraform-generator)

cli-terraform-generator cannot generate these resources: their required create fields
(members on pairs, endpoints on endpoints) are arrays-of-objects, which the generator's CLI parser
does not represent as flags (documented limitation — parser_cli.go skips non-string arrays as
"require custom code"). So the commands are hand-written, with --member name=id / --endpoint name=…,resource-id=…,… parsing, and the custom failover/activate actions the generator doesn't emit.

Dependency / draft status

Requires github.com/confluentinc/ccloud-sdk-go-v2/switchover v0.1.0 (in review; not yet published).
go build ./internal/ ./internal/switchover/... ./pkg/ccloudv2/... passes locally against the SDK.
CI will fail until the SDK publishes; golden files still need generating
(make integration-test INTEGRATION_TEST_ARGS="-run TestSwitchover -update"). Opened as draft.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 12, 2026 19:25
@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.

@wyuzheng Ethan Wang (wyuzheng) marked this pull request as ready for review June 12, 2026 19:26
@wyuzheng Ethan Wang (wyuzheng) requested a review from a team as a code owner June 12, 2026 19:26
@wyuzheng Ethan Wang (wyuzheng) marked this pull request as draft June 12, 2026 19:27

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

This PR introduces a new confluent switchover command group for Kafka Disaster Recovery, adding CLI support for managing switchover pairs and switchover endpoints (including custom actions failover and activate) backed by a new ccloudv2 SDK wrapper and test-server mocks.

Changes:

  • Add internal/switchover command tree with CRUD + action commands and output structs.
  • Add pkg/ccloudv2 Switchover API client wrapper and register it in the shared ccloudv2 client.
  • Add integration test coverage scaffolding and test-server routes/handlers for the switchover APIs.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/command.go Registers the new top-level switchover command.
internal/switchover/* Implements switchover pair and switchover endpoint commands, parsing, and output formatting.
pkg/ccloudv2/client.go Adds and initializes SwitchoverClient in the shared ccloudv2 client.
pkg/ccloudv2/switchover.go Adds Switchover API wrapper methods (create/list/describe/update/delete + failover/activate).
pkg/resource/resource.go Adds resource name constants for deletion prompts/messages.
test/test-server/ccloudv2_router.go Registers switchover API routes in the test server router.
test/test-server/switchover_handler.go Adds mock handlers/builders for switchover pairs/endpoints (list/create/describe/update/delete + actions).
test/switchover_test.go Adds integration test cases referencing golden fixtures for switchover commands.
go.mod Adds dependency on github.com/confluentinc/ccloud-sdk-go-v2/switchover v0.1.0.

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

Comment on lines +43 to +48
switch r.Method {
case http.MethodGet, http.MethodPut:
require.NoError(t, json.NewEncoder(w).Encode(buildPair(id, "prod-kafka-dr")))
case http.MethodDelete:
w.WriteHeader(http.StatusNoContent)
}
Comment on lines +55 to +58
id := mux.Vars(r)["id"]
pair := buildPair(id, "prod-kafka-dr")
pair.Status.SetPhase("SWITCHING")
require.NoError(t, json.NewEncoder(w).Encode(pair))
Comment on lines +89 to +94
switch r.Method {
case http.MethodGet, http.MethodPut:
require.NoError(t, json.NewEncoder(w).Encode(buildEndpoint(id, "prod-kafka-dr-endpoint")))
case http.MethodDelete:
w.WriteHeader(http.StatusNoContent)
}
Comment thread test/switchover_test.go
Comment on lines +4 to +21
tests := []CLITest{
// SwitchoverPair
{args: "switchover pair create prod-kafka-dr --member west=lkc-111111 --member east=lkc-222222 --active-member west", fixture: "switchover/pair/create.golden"},
{args: "switchover pair list", fixture: "switchover/pair/list.golden"},
{args: "switchover pair describe sw-123456", fixture: "switchover/pair/describe.golden"},
{args: "switchover pair update sw-123456 --name renamed-dr", fixture: "switchover/pair/update.golden"},
{args: "switchover pair failover sw-123456 --member east --type CLEAN", fixture: "switchover/pair/failover.golden"},
{args: "switchover pair delete sw-123456 --force", fixture: "switchover/pair/delete.golden"},
{args: "switchover pair describe sw-000000", fixture: "switchover/pair/describe-not-found.golden", exitCode: 1},
{args: "switchover pair describe sw-123456 --output json", fixture: "switchover/pair/describe-json.golden"},

// SwitchoverEndpoint
{args: "switchover endpoint create prod-endpoint --switchover-pair sw-123456 --endpoint name=west-platt,resource-id=lkc-111111,type=PRIVATE --endpoint name=east-platt,resource-id=lkc-222222,type=PRIVATE", fixture: "switchover/endpoint/create.golden"},
{args: "switchover endpoint list", fixture: "switchover/endpoint/list.golden"},
{args: "switchover endpoint describe se-123456", fixture: "switchover/endpoint/describe.golden"},
{args: "switchover endpoint activate se-123456", fixture: "switchover/endpoint/activate.golden"},
{args: "switchover endpoint delete se-123456 --force", fixture: "switchover/endpoint/delete.golden"},
}
@airlock-confluentinc airlock-confluentinc Bot force-pushed the ORC-10127-add-switchover-commands branch from 710480f to 5b8b86a Compare June 12, 2026 19:53
Adds `confluent switchover pair` and `confluent switchover endpoint` commands
(create/list/describe/update/delete + `pair failover` and `endpoint activate`),
the ccloudv2 SDK wrapper, output structs, resource constants, command + client
registration, and test-server handlers.

Hand-written: cli-terraform-generator cannot generate these resources because
their required create fields (members, endpoints) are arrays-of-objects, which
its CLI parser does not represent as flags (documented limitation).

Builds against switchover/v1 SDK; go build of internal/, internal/switchover,
pkg/ccloudv2 passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@airlock-confluentinc airlock-confluentinc Bot force-pushed the ORC-10127-add-switchover-commands branch from 5b8b86a to e1801fa Compare June 12, 2026 20:36
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