[APIE-933] Migrate the confluent environment commands exclude the integration test - #3427
Conversation
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
There was a problem hiding this comment.
Pull request overview
This PR updates the Confluent Cloud environment and RTCE command surfaces (and their test harness/goldens) as part of a generator-driven migration, including a bump of the ccloud-sdk-go-v2/org dependency and corresponding client signature changes.
Changes:
- Regenerates/migrates Environment and RTCE Region command implementations and help text (plus associated fixtures).
- Updates
pkg/ccloudv2org client methods to return*http.Response(and adjusts call sites accordingly). - Adds/adjusts test-server behavior and live tests to align with updated API/request defaults.
Reviewed changes
Copilot reviewed 49 out of 57 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test-server/region_handler.go | Adds generator header to test-server handler source. |
| test/test-server/org_handlers.go | Updates mock org environment creation to default stream governance config when omitted. |
| test/region_test.go | Adds generator header to region integration test. |
| test/live/region_live_test.go | Adds generated RTCE region live test (list). |
| test/live/environment_live_test.go | Updates generated live test flow/state variable naming for environments. |
| test/fixtures/output/rtce/rtce-topic/update-help.golden | Updates RTCE topic update short description in help output. |
| test/fixtures/output/rtce/rtce-topic/help.golden | Updates RTCE topic command help strings. |
| test/fixtures/output/rtce/region/help.golden | Updates RTCE region command help strings. |
| test/fixtures/output/rtce/help.golden | Updates top-level RTCE help strings. |
| test/fixtures/output/environment/use-help.golden | Updates environment use long help text. |
| test/fixtures/output/environment/update-help.golden | Updates environment update help/flag text. |
| test/fixtures/output/environment/list-help.golden | Updates environment list help text. |
| test/fixtures/output/environment/help.golden | Updates top-level environment help strings. |
| test/fixtures/output/environment/describe-help.golden | Updates environment describe help text. |
| test/fixtures/output/environment/delete-help.golden | Updates environment delete help text. |
| test/fixtures/output/environment/create-help.golden | Updates environment create help/flag text. |
| test/fixtures/output/environment/3.golden | Updates expected output for environment update scenario. |
| pkg/cmd/flags.go | Updates environment autocomplete to match new GetOrgEnvironment return signature. |
| pkg/ccloudv2/rtce.go | Reorders RTCE regions API helpers (no functional change intended). |
| pkg/ccloudv2/org.go | Refactors org + environment API wrappers; environment calls now return *http.Response for richer error handling by callers. |
| internal/rtce/command_rtce_topic.go | Updates RTCE topic command short help string. |
| internal/rtce/command_rtce_topic_update.go | Updates RTCE topic update short help string. |
| internal/rtce/command_region.go | Adds generator header and updates RTCE region command short help string. |
| internal/rtce/command_region_list.go | Adds generator header to RTCE region list command. |
| internal/flink/command_statement_create.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_shell.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_materialized_table_update.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_materialized_table_list.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_materialized_table_describe.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_materialized_table_delete.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_materialized_table_create.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_connection_update.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_connection_list.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_connection_describe.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_connection_delete.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_connection_create.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_compute_pool_update.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_compute_pool_create.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_artifact_list.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_artifact_describe.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_artifact_delete.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/flink/command_artifact_create.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/environment/command.go | Migrates environment root command; introduces shared table output + custom completions. |
| internal/environment/command_use.go | Migrates environment use to new org client signatures and error catching. |
| internal/environment/command_update.go | Migrates environment update to new org client signatures and output behavior. |
| internal/environment/command_list.go | Migrates environment list to new output struct and command type. |
| internal/environment/command_describe.go | Migrates environment describe to shared print helper and new org client signature. |
| internal/environment/command_delete.go | Migrates environment delete to string resource type and adjusts config cleanup behavior. |
| internal/environment/command_create.go | Migrates environment create to new org client signature and revised governance handling. |
| internal/connect/command_artifact_list.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/connect/command_artifact_describe.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/connect/command_artifact_delete.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/connect/command_artifact_create.go | Adjusts for new GetOrgEnvironment return signature. |
| internal/command.go | Updates root command wiring to pass config into environment command constructor. |
| go.mod | Bumps github.com/confluentinc/ccloud-sdk-go-v2/org to v0.13.0. |
| go.sum | Updates checksums for ccloud-sdk-go-v2/org v0.13.0. |
| .cli-generation-checksum | Updates generator checksum. |
Files not reviewed (7)
- internal/environment/command.go: Generated file
- internal/environment/command_create.go: Generated file
- internal/environment/command_delete.go: Generated file
- internal/environment/command_describe.go: Generated file
- internal/environment/command_list.go: Generated file
- internal/environment/command_update.go: Generated file
- internal/environment/command_use.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 49 out of 57 changed files in this pull request and generated no new comments.
Files not reviewed (7)
- internal/environment/command.go: Generated file
- internal/environment/command_create.go: Generated file
- internal/environment/command_delete.go: Generated file
- internal/environment/command_describe.go: Generated file
- internal/environment/command_list.go: Generated file
- internal/environment/command_update.go: Generated file
- internal/environment/command_use.go: Generated file
Suppressed comments (21)
internal/environment/command_update.go:67
output.Printfalways writes to stdout, so printing the "Updated environment ..." line unconditionally will corrupt-o json/-o yamloutput (it will prepend a human-readable line before the serialized payload). Gate this message to human output only.
internal/flink/command_statement_create.go:66GetOrgEnvironmentnow returns the raw SDK error; returningerr.Error()here can surface unformatted API errors and miss the CLI's standard CCloud v2 error parsing. Capture the HTTP response and wrap viaerrors.CatchCCloudV2Errorbefore building the user-facing error.
internal/flink/command_shell.go:179GetOrgEnvironmentnow returns the raw SDK error; usingerr.Error()directly here can leak unformatted API errors. Capture the HTTP response and wrap viaerrors.CatchCCloudV2Errorso the shell prints consistent CLI errors.
internal/flink/command_materialized_table_update.go:61- This environment existence check now discards the HTTP response from
GetOrgEnvironment, and the returned error is the raw SDK error. Wrap it witherrors.CatchCCloudV2Errorbefore using it as the primary error message so users get consistent, parsed CCloud v2 errors.
internal/flink/command_materialized_table_list.go:38 GetOrgEnvironmentnow returns raw SDK errors; usingerr.Error()here can produce noisy/unparsed output. Capture the HTTP response and wrap the error viaerrors.CatchCCloudV2Errorbefore surfacing it to the user.
if _, _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil {
return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId))
}
internal/flink/command_materialized_table_describe.go:42
- This path uses
err.Error()from the raw SDK error returned byGetOrgEnvironment. Wrap the error witherrors.CatchCCloudV2Error(using the HTTP response) to preserve consistent CLI error formatting.
if _, _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil {
return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId))
}
internal/flink/command_materialized_table_delete.go:43
GetOrgEnvironmentnow returns a raw SDK error; returningerr.Error()here can leak unparsed API error details and be inconsistent with other CCloud v2 error handling. Wrap viaerrors.CatchCCloudV2Errorusing the HTTP response.
if _, _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil {
return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId))
}
internal/flink/command_materialized_table_create.go:83
- This environment validation returns
err.Error()from the raw SDK error returned byGetOrgEnvironment. Capture the HTTP response and wrap the error viaerrors.CatchCCloudV2Errorso the user gets a parsed, consistent error message.
if _, _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil {
return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId))
}
internal/flink/command_connection_update.go:53
GetOrgEnvironmentnow returns raw SDK errors; usingerr.Error()directly can expose unparsed API errors. Capture the HTTP response and wrap witherrors.CatchCCloudV2Errorbefore building the CLI error message.
if _, _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil {
return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId))
}
internal/flink/command_connection_list.go:44
GetOrgEnvironmentnow returns a raw SDK error; usingerr.Error()directly can expose unparsed API errors. Capture the HTTP response and wrap viaerrors.CatchCCloudV2Errorbefore returning a CLI error.
if _, _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil {
return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId))
}
internal/flink/command_connection_describe.go:41
- This environment lookup now yields raw SDK errors; returning
err.Error()can lead to noisy/unparsed messages. Capture the HTTP response and wrap witherrors.CatchCCloudV2Errorbefore surfacing it to the user.
if _, _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil {
return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId))
}
internal/flink/command_connection_delete.go:43
GetOrgEnvironmentnow returns raw SDK errors; usingerr.Error()directly can expose unparsed API errors. Capture the HTTP response and wrap witherrors.CatchCCloudV2Errorso the CLI error is consistent.
if _, _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil {
return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId))
}
internal/flink/command_connection_create.go:83
- This environment validation returns
err.Error()from the raw SDK error returned byGetOrgEnvironment. Capture the HTTP response and wrap viaerrors.CatchCCloudV2Errorbefore returning a CLI error.
if _, _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil {
return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId))
}
internal/connect/command_artifact_list.go:49
- This converts any
GetOrgEnvironmentfailure (including auth/network errors) into a misleading "not found" error. SinceGetOrgEnvironmentnow returns raw SDK errors, keep the original error context to avoid masking real failures.
if _, _, err = c.V2Client.GetOrgEnvironment(environment); err != nil {
return fmt.Errorf("environment '%s' not found", environment)
}
internal/connect/command_artifact_describe.go:48
- This reports "environment not found" for any failure returned by
GetOrgEnvironment, which can mask auth/network issues. Preserve the underlying error so users can diagnose the real cause.
if _, _, err = c.V2Client.GetOrgEnvironment(environment); err != nil {
return fmt.Errorf("environment '%s' not found", environment)
}
internal/connect/command_artifact_delete.go:50
- This turns all
GetOrgEnvironmenterrors into a "not found" message, which can be inaccurate (e.g., forbidden, network failure). Preserve and wrap the original error instead of rewriting it.
if _, _, err = c.V2Client.GetOrgEnvironment(environment); err != nil {
return fmt.Errorf("environment '%s' not found", environment)
}
internal/connect/command_artifact_create.go:66
- This rewrites any error from
GetOrgEnvironmentas "not found", masking other failure modes (auth, transient API errors). Preserve the underlying error context by wrapping it instead.
if _, _, err = c.V2Client.GetOrgEnvironment(environment); err != nil {
return fmt.Errorf("environment '%s' not found", environment)
}
internal/flink/command_artifact_create.go:100
- This rewrites all
GetOrgEnvironmenterrors as "not found", masking other common failure modes (e.g., forbidden or transient API errors). Wrap and return the original error instead of replacing it.
if _, _, err = c.V2Client.GetOrgEnvironment(environment); err != nil {
return fmt.Errorf("environment '%s' not found", environment)
}
internal/flink/command_compute_pool_create.go:70
GetOrgEnvironmentnow returns raw SDK errors; returningerrdirectly here can leak unparsed API errors and be inconsistent with otherV2Clienthelpers that wrap errors viaerrors.CatchCCloudV2Error. Consider capturinghttpRespfromGetOrgEnvironmentand returningerrors.CatchCCloudV2Error(err, httpResp)instead.
environment, _, err := c.V2Client.GetOrgEnvironment(environmentId)
if err != nil {
return err
}
internal/flink/command_compute_pool_update.go:66
GetOrgEnvironmentnow returns raw SDK errors; returningerrdirectly here can surface unparsed API errors. Capture the HTTP response fromGetOrgEnvironmentand wrap viaerrors.CatchCCloudV2Errorfor consistent CLI error formatting.
environment, _, err := c.V2Client.GetOrgEnvironment(environmentId)
if err != nil {
return err
}
internal/flink/command_artifact_list.go:64
- This reports "environment not found" for any error from
GetOrgEnvironment, which can mask auth/network/API failures. Preserve the underlying error context so users can diagnose the real failure mode.
if _, _, err = c.V2Client.GetOrgEnvironment(environment); err != nil {
return fmt.Errorf("environment '%s' not found", environment)
}
| StreamGovernancePackage: environment.StreamGovernanceConfig.GetPackage(), | ||
| }) | ||
| return table.Print() | ||
| output.Printf(c.Config.EnableColor, "Updated environment \"%s\".\n", id) |
There was a problem hiding this comment.
This update command has json/yaml output, so printing this message to stdout is a breaking change.
I think we should only print this message for resources that do not contain output.
There was a problem hiding this comment.
It seems ok:
Official version:
channingdong@CLK32PJ63L cli % confluent shell
> confluent env update env-0d1606 --name verify_output -o yaml
is_current: false
id: env-0d1606
name: verify_output
stream_governance_package: ESSENTIALS
> confluent env update env-0d1606 --name verify_output -o json
{
"is_current": false,
"id": "env-0d1606",
"name": "verify_output",
"stream_governance_package": "ESSENTIALS"
}
> confluent exit
Engineering version:
channingdong@CLK32PJ63L cli % dist/confluent_darwin_arm64_v8.0/confluent shell
> confluent env update env-0d1606 --name engineering_verify_output -o json
Updated environment "env-0d1606".
{
"is_current": false,
"id": "env-0d1606",
"name": "engineering_verify_output",
"stream_governance_package": "ESSENTIALS"
}
> confluent env update env-0d1606 --name engineering_verify_output -o yaml
Updated environment "env-0d1606".
is_current: false
id: env-0d1606
name: engineering_verify_output
stream_governance_package: ESSENTIALS
There was a problem hiding this comment.
The issue is that you cannot parse the json anymore because "Updated environment..." is not json:
confluent environment update env-<redacted> --name "testing" -o json | jq '.name'
jq: parse error: Invalid numeric literal at line 1, column 8
main for comparison:
confluent environment update env-<redacted> --name "testing" -o json | jq '.name'
"testing"
There was a problem hiding this comment.
Fixed:
channingdong@CLK32PJ63L cli % dist/confluent_darwin_arm64_v8.0/confluent environment update env-0d1606 --name "testing" -o json | jq '.name'
"testing"
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 49 out of 57 changed files in this pull request and generated no new comments.
Files not reviewed (7)
- internal/environment/command.go: Generated file
- internal/environment/command_create.go: Generated file
- internal/environment/command_delete.go: Generated file
- internal/environment/command_describe.go: Generated file
- internal/environment/command_list.go: Generated file
- internal/environment/command_update.go: Generated file
- internal/environment/command_use.go: Generated file
Suppressed comments (2)
internal/environment/command_describe.go:46
environment describenow returns the raw CCloud V2 error without any guidance on what to do next (unlikeenvironment use, and the previous behavior). For common failures like an unknown environment ID, adding a suggestion to runconfluent environment listimproves UX consistency.
test/live/environment_live_test.go:54- The live CRUD test no longer verifies that the update actually changed the environment name; it only checks exit code. Re-adding a describe/assert step after the update will catch regressions where the update is accepted but ignored or only partially applied.
|




Release Notes
Breaking Changes
New Features
Bug Fixes
Checklist
Whatsection below whether this PR applies to Confluent Cloud, Confluent Platform, or both.Test & Reviewsection below.Blast Radiussection below.What
(Internal) This PR migrates the manually developed code for
confluent environmentcommands to the auto-generated code as an effort to onboard Project Tigris going forward.In addition, this PR improves the command help text message to be more accurate and descriptive.
Blast Radius
Minimal, comprehensive validation (not exhaustive though) has been performed to guarantee the functionally equivalent from the generated code.
In the worst case, users of
confluent environmentcommands may notice minor cosmetic differences — for example, the environment command's help text changes from "Manage environments." to "Manage and select Confluent Cloud environments.", which are essentially improvements.Same command helper text messages have been applied to multiple resources as well.
References
https://confluentinc.atlassian.net/browse/APIE-933
Test & Review
#1: create a new essentials environment
#2: describe this new essentials environment
#3: update this new essentials environment with a different name
#4: create a new advanced environment
#5: describe this new advanced environment
#6: update this new advanced environment with different package type (downgrade), without provisioning the schema registry cluster, this is feasible.
#7: list all existing environments
#8: try the new
useenvironment command and evaluate theCurrentfield#9: delete both environments and confirm they are absent after deletion