-
Notifications
You must be signed in to change notification settings - Fork 26
Add cli command to show CMF system-info #3316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,89 @@ | ||||||||||||||||||||||||||||
| package flink | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||
| "github.com/spf13/cobra" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| pcmd "github.com/confluentinc/cli/v4/pkg/cmd" | ||||||||||||||||||||||||||||
| "github.com/confluentinc/cli/v4/pkg/output" | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| type systemInfoOut struct { | ||||||||||||||||||||||||||||
| Version string `human:"Version" serialized:"version"` | ||||||||||||||||||||||||||||
| Revision string `human:"Revision" serialized:"revision"` | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| type localSystemInformation struct { | ||||||||||||||||||||||||||||
| Status *localSystemInformationStatus `json:"status,omitempty" yaml:"status,omitempty"` | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| type localSystemInformationStatus struct { | ||||||||||||||||||||||||||||
| Version *string `json:"version,omitempty" yaml:"version,omitempty"` | ||||||||||||||||||||||||||||
| Revision *string `json:"revision,omitempty" yaml:"revision,omitempty"` | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| func (c *command) systemInfo(cmd *cobra.Command, _ []string) error { | ||||||||||||||||||||||||||||
| client, err := c.GetCmfClient(cmd) | ||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| result, err := client.GetSystemInformation(c.createContext()) | ||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| sysInfo := parseSystemInformation(result) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if output.GetFormat(cmd) == output.Human { | ||||||||||||||||||||||||||||
| table := output.NewTable(cmd) | ||||||||||||||||||||||||||||
| table.Add(&systemInfoOut{ | ||||||||||||||||||||||||||||
| Version: derefString(sysInfo.Status.Version), | ||||||||||||||||||||||||||||
| Revision: derefString(sysInfo.Status.Revision), | ||||||||||||||||||||||||||||
|
Comment on lines
+53
to
+56
|
||||||||||||||||||||||||||||
| 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), |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ package flink | |||||
|
|
||||||
| import ( | ||||||
| "context" | ||||||
| "encoding/json" | ||||||
| "errors" | ||||||
| "fmt" | ||||||
| "io" | ||||||
|
|
@@ -35,6 +36,7 @@ type CmfClientInterface interface { | |||||
| DeleteStatement(ctx context.Context, environment, statement string) error | ||||||
| UpdateStatement(ctx context.Context, environment, statementName string, statement cmfsdk.Statement) error | ||||||
| GetStatementResults(ctx context.Context, environment, statementName, pageToken string) (cmfsdk.StatementResult, error) | ||||||
| GetSystemInformation(ctx context.Context) (map[string]interface{}, error) | ||||||
| CmfApiContext() context.Context | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -529,6 +531,46 @@ func (cmfClient *CmfRestClient) GetStatementResults(ctx context.Context, environ | |||||
| return resp, nil | ||||||
| } | ||||||
|
|
||||||
| func (cmfClient *CmfRestClient) GetSystemInformation(ctx context.Context) (map[string]interface{}, error) { | ||||||
| baseURL := cmfClient.GetConfig().Servers[0].URL | ||||||
|
||||||
| baseURL := cmfClient.GetConfig().Servers[0].URL | |
| baseURL := strings.TrimRight(cmfClient.GetConfig().Servers[0].URL, "/") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| 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") | ||
|
|
||
| Global Flags: | ||
| -h, --help Show help for this command. | ||
| --unsafe-trace Equivalent to -vvvv, but also log HTTP requests and responses which might contain plaintext secrets. | ||
| -v, --verbose count Increase verbosity (-v for warn, -vv for info, -vvv for debug, -vvvv for trace). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "status": { | ||
| "version": "1.0.0", | ||
| "revision": "abc1234def5678" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| status: | ||
| version: 1.0.0 | ||
| revision: abc1234def5678 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| +----------+----------------+ | ||
| | Version | 1.0.0 | | ||
| | Revision | abc1234def5678 | | ||
| +----------+----------------+ |
There was a problem hiding this comment.
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 causeTestHelpto fail for the on-prem configuration.