Skip to content

Add cli command to show CMF system-info#3316

Open
Paras Negi (paras-negi-flink) wants to merge 4 commits into
mainfrom
CF-3139
Open

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

Conversation

@paras-negi-flink

@paras-negi-flink Paras Negi (paras-negi-flink) commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Release Notes

Breaking Changes

  • None

New Features

  • Added confluent flink system-info command to display CMF system information (version and revision) in Confluent Platform.

Bug Fixes

  • None

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

This PR implements CF-3139 — Show CMF system information for the Confluent CLI, targeting Confluent Platform / CP Flink (CMF on-prem):

  • Adds a new command under confluent flink:
    • confluent flink system-info
  • Wires this command to the CMF system information REST API:
    • GET /cmf/api/v1/system-information
  • Adds a CmfRestClient wrapper (GetSystemInformation) and corresponding local types/output formatting (human, json, yaml), following existing patterns used for catalogs, databases, and compute pools.
  • Hardening (from review feedback):
    • Guards against a nil status in the human-output path, so a status-less CMF response fails gracefully instead of panicking.
    • Normalizes the CMF base URL (trims a trailing slash) before building the request path, avoiding malformed //cmf/api/... requests.

Blast Radius

  • Scope is limited to the new confluent flink system-info command; existing CLI behavior is unchanged.
  • If something goes wrong:
    • Impact is confined to users running confluent flink system-info.
    • The command may fail or surface CMF errors, or not show the correct version/revision; CMF remains the source of truth.
  • There are no breaking changes to existing commands, flags, or APIs. Reverting is straightforward (command + client wrapper).

References

Test & Review

Environment

  • Repo: confluentinc/cli
  • Branch: CF-3139
  • CMF: 2.3-SNAPSHOT
  • Verified via the CLI integration test suite (TestFlinkSystemInfo, run in both on-prem and cloud-logout modes against the CMF test server); make build and go vet are clean.

CLI output (test server returns version 1.0.0, revision abc1234def5678)

  1. Help
% ./confluent flink system-info --help
Display CMF system information.

Usage:
  confluent flink system-info [flags]

Flags:
      --url string                          Base URL of the Confluent Manager for Apache Flink (CMF). Environment variable "CONFLUENT_CMF_URL" may be set in place of this flag.
      --client-key-path string              Path to client private key for mTLS authentication. Environment variable "CONFLUENT_CMF_CLIENT_KEY_PATH" may be set in place of this flag.
      --client-cert-path string             Path to client cert to be verified by Confluent Manager for Apache Flink. Include for mTLS authentication. Environment variable "CONFLUENT_CMF_CLIENT_CERT_PATH" may be set in place of this flag.
      --certificate-authority-path string   Path to a PEM-encoded Certificate Authority to verify the Confluent Manager for Apache Flink connection. Environment variable "CONFLUENT_CMF_CERTIFICATE_AUTHORITY_PATH" may be set in place of this flag.
  -o, --output string                       Specify the output format as "human", "json", or "yaml". (default "human")
  1. Human / JSON / YAML output
% ./confluent flink system-info --url http://localhost:8080
+----------+----------------+
| Version  | 1.0.0          |
| Revision | abc1234def5678 |
+----------+----------------+

% ./confluent flink system-info --url http://localhost:8080 --output json
{
  "status": {
    "version": "1.0.0",
    "revision": "abc1234def5678"
  }
}

% ./confluent flink system-info --url http://localhost:8080 --output yaml
status:
    version: 1.0.0
    revision: abc1234def5678

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.

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 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 thread internal/flink/command_system_info.go Outdated
Comment on lines +53 to +56
table := output.NewTable(cmd)
table.Add(&systemInfoOut{
Version: derefString(sysInfo.Status.Version),
Revision: derefString(sysInfo.Status.Revision),

Copilot AI Apr 11, 2026

Copy link

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

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
}

Copilot AI Apr 11, 2026

Copy link

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.
Comment thread pkg/flink/cmf_rest_client.go Outdated
}

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

Copilot AI Apr 11, 2026

Copy link

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Resolved.

- 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

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Avoid a nil-pointer panic in human output when the CMF response has no status, and trim a trailing slash from the base URL before building the system-information request path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@paras-negi-flink Paras Negi (paras-negi-flink) marked this pull request as ready for review June 23, 2026 19:14
@paras-negi-flink Paras Negi (paras-negi-flink) requested a review from a team as a code owner June 23, 2026 19:14
@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.

3 participants