Skip to content

Add cli command to show CMF system-info#3316

Draft
Paras Negi (paras-negi-flink) wants to merge 2 commits intomainfrom
CF-3139
Draft

Add cli command to show CMF system-info#3316
Paras Negi (paras-negi-flink) wants to merge 2 commits intomainfrom
CF-3139

Conversation

@paras-negi-flink
Copy link
Copy Markdown

Release Notes

Breaking Changes

  • PLACEHOLDER

New Features

  • PLACEHOLDER

Bug Fixes

  • PLACEHOLDER

Checklist

  • I have successfully built and used a custom CLI binary, without linter issues from this PR.
  • I have clearly specified in the What section below whether this PR applies to Confluent Cloud, Confluent Platform, or both.
  • I have verified this PR in Confluent Cloud pre-prod or production environment, if applicable.
  • I have verified this PR in Confluent Platform on-premises environment, if applicable.
  • I have attached manual CLI verification results or screenshots in the Test & Review section below.
  • I have added appropriate CLI integration or unit tests for any new or updated commands and functionality.
  • I confirm that this PR introduces no breaking changes or backward compatibility issues.
  • I have indicated the potential customer impact if something goes wrong in the Blast Radius section below.
  • I have put checkmarks below confirming that the feature associated with this PR is enabled in:
    • Confluent Cloud prod
    • Confluent Cloud stag
    • Confluent Platform
    • Check this box if the feature is enabled for certain organizations only

What

Blast Radius

References

Test & Review

Copilot AI review requested due to automatic review settings April 11, 2026 03:58
@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.

Copy link
Copy Markdown

Copilot AI left a comment

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 on-prem Flink CLI subcommand to display CMF “system information” (version/revision), backed by a new CMF REST client call and test-server route/fixtures.

Changes:

  • Introduce flink system-info command with human + JSON/YAML output.
  • Add CMF client support for /cmf/api/v1/system-information and corresponding test-server handler/route.
  • Add integration tests and golden fixtures for system-info output and update on-prem flink help output.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/flink/command.go Registers the new system-info subcommand under flink (on-prem specific commands).
internal/flink/command_system_info.go Implements flink system-info command, parsing and output formatting.
pkg/flink/cmf_rest_client.go Adds GetSystemInformation method to call CMF system-information endpoint.
pkg/flink/test/mock/cmf_client_mock.go Updates gomock client interface with GetSystemInformation.
test/test-server/flink_onprem_router.go Wires new system-information route into the on-prem test router.
test/test-server/flink_onprem_handler.go Adds handler returning stubbed system info payload for tests.
test/flink_onprem_test.go Adds integration test coverage for flink system-info across output formats.
test/fixtures/output/flink/system-info.golden Golden fixture for human/table output.
test/fixtures/output/flink/system-info-json.golden Golden fixture for JSON output.
test/fixtures/output/flink/system-info-yaml.golden Golden fixture for YAML output.
test/fixtures/output/flink/help-onprem.golden Updates on-prem flink --help to include system-info.

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

Comment on lines +53 to +56
table := output.NewTable(cmd)
table.Add(&systemInfoOut{
Version: derefString(sysInfo.Status.Version),
Revision: derefString(sysInfo.Status.Revision),
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sysInfo.Status can be nil when the CMF response is missing/invalid status, but the human-output branch unconditionally dereferences sysInfo.Status.Version/Revision, which will panic. Guard against sysInfo.Status == nil (or initialize a non-nil status before dereferencing) so the command fails gracefully instead of crashing.

Suggested change
table := output.NewTable(cmd)
table.Add(&systemInfoOut{
Version: derefString(sysInfo.Status.Version),
Revision: derefString(sysInfo.Status.Revision),
status := &localSystemInformationStatus{}
if sysInfo.Status != nil {
status = sysInfo.Status
}
table := output.NewTable(cmd)
table.Add(&systemInfoOut{
Version: derefString(status.Version),
Revision: derefString(status.Revision),

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +37
func (c *command) newSystemInfoCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "system-info",
Short: "Display CMF system information.",
Args: cobra.NoArgs,
RunE: c.systemInfo,
Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireCloudLogout},
}

addCmfFlagSet(cmd)
pcmd.AddOutputFlag(cmd)

return cmd
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recursive help golden tests expect a fixture for the leaf command help output (e.g., test/fixtures/output/flink/system-info-help-onprem.golden). Adding this command without the corresponding help fixture will cause TestHelp to fail for the on-prem configuration.

Copilot uses AI. Check for mistakes.
}

func (cmfClient *CmfRestClient) GetSystemInformation(ctx context.Context) (map[string]interface{}, error) {
baseURL := cmfClient.GetConfig().Servers[0].URL
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building the request URL via string concatenation can produce an invalid path when the configured base URL ends with / (resulting in //cmf/api/...). Prefer joining/normalizing the base URL (e.g., trimming the trailing slash or using url.JoinPath) to ensure the request is well-formed.

Suggested change
baseURL := cmfClient.GetConfig().Servers[0].URL
baseURL := strings.TrimRight(cmfClient.GetConfig().Servers[0].URL, "/")

Copilot uses AI. Check for mistakes.
- Remove quotes around version in YAML golden (YAML serializer doesn't quote version-like strings)
- Reorder help-onprem.golden so system-info sorts after statement (cobra alphabetical ordering)
- Add missing system-info-help-onprem.golden for auto-generated help tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sonarqube-confluent
Copy link
Copy Markdown

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