[ORC-10127] Add switchover CLI commands (pair, endpoint)#3382
Draft
Ethan Wang (wyuzheng) wants to merge 1 commit into
Draft
[ORC-10127] Add switchover CLI commands (pair, endpoint)#3382Ethan Wang (wyuzheng) wants to merge 1 commit into
Ethan Wang (wyuzheng) wants to merge 1 commit into
Conversation
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
There was a problem hiding this comment.
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/switchovercommand tree with CRUD + action commands and output structs. - Add
pkg/ccloudv2Switchover API client wrapper and register it in the sharedccloudv2client. - 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 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"}, | ||
| } |
710480f to
5b8b86a
Compare
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>
5b8b86a to
e1801fa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
confluent switchoverCLI commands for the Kafka DR Switchover API (ORC-10127 of ORC-9794):confluent switchover pair—create/list/describe/update/delete/failoverconfluent switchover endpoint—create/list/describe/update/delete/activatePlus the
ccloudv2SDK wrapper, output structs,resourceconstants, command + client registration,and test-server mock handlers.
Why hand-written (not cli-terraform-generator)
cli-terraform-generatorcannot generate these resources: their required create fields(
memberson pairs,endpointson endpoints) are arrays-of-objects, which the generator's CLI parserdoes not represent as flags (documented limitation —
parser_cli.goskips non-string arrays as"require custom code"). So the commands are hand-written, with
--member name=id/--endpoint name=…,resource-id=…,…parsing, and the customfailover/activateactions 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