Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions internal/usm/command_connect_cluster.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Code generated by cli-terraform-generator; DO NOT EDIT.

package usm

import (
Expand All @@ -19,9 +17,9 @@ type connectClusterCommand struct {
type connectClusterOut struct {
ID string `human:"ID" serialized:"id"`
ConfluentPlatformConnectCluster string `human:"Confluent Platform Connect Cluster" serialized:"confluent_platform_connect_cluster"`
ConfluentPlatformKafkaClusterId string `human:"Confluent Platform Kafka Cluster Id" serialized:"confluent_platform_kafka_cluster_id"`
Environment string `human:"Environment" serialized:"environment"`
KafkaClusterId string `human:"Kafka Cluster Id" serialized:"kafka_cluster_id"`
UsmKafkaClusterId string `human:"USM Kafka Cluster Id" serialized:"usm_kafka_cluster_id"`
Environment string `human:"Environment" serialized:"environment"`
Cloud string `human:"Cloud" serialized:"cloud"`
Region string `human:"Region" serialized:"region"`
}
Expand Down Expand Up @@ -53,7 +51,7 @@ func printConnectCluster(cmd *cobra.Command, connectCluster usmv1.UsmV1ConnectCl
out := &connectClusterOut{
ID: connectCluster.GetId(),
ConfluentPlatformConnectCluster: connectCluster.GetConfluentPlatformConnectClusterId(),
ConfluentPlatformKafkaClusterId: connectCluster.GetKafkaClusterId(),
KafkaClusterId: connectCluster.GetKafkaClusterId(),
Environment: connectCluster.Environment.GetId(),
UsmKafkaClusterId: connectCluster.GetUsmKafkaClusterId(),
Cloud: connectCluster.GetCloud(),
Expand Down
15 changes: 11 additions & 4 deletions internal/usm/command_connect_cluster_create.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Code generated by cli-terraform-generator; DO NOT EDIT.

package usm
Comment thread
FlamedHunter marked this conversation as resolved.

import (
Expand Down Expand Up @@ -29,9 +27,9 @@
),
}

// Required flags
// Kafka cluster flags (exactly one required, mutually exclusive)
cmd.Flags().String("confluent-platform-kafka-cluster", "", "The unique identifier of the metadata Kafka cluster for the Connect Cluster.")

Check failure on line 31 in internal/usm/command_connect_cluster_create.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "confluent-platform-kafka-cluster" 4 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3449&issues=6d2a7e57-7811-40d1-8e78-c4ace4552858&open=6d2a7e57-7811-40d1-8e78-c4ace4552858
cobra.CheckErr(cmd.MarkFlagRequired("confluent-platform-kafka-cluster"))
cmd.Flags().String("kafka-cluster", "", "The unique identifier of the metadata Kafka cluster for the Connect Cluster.")

Check failure on line 32 in internal/usm/command_connect_cluster_create.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "kafka-cluster" 5 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3449&issues=02def770-6ea1-43de-9748-896250c025e7&open=02def770-6ea1-43de-9748-896250c025e7

// Optional flags
pcmd.AddCloudFlag(cmd)
Expand All @@ -41,6 +39,9 @@
pcmd.AddContextFlag(cmd, c.CLICommand)
pcmd.AddOutputFlag(cmd)

cmd.MarkFlagsOneRequired("confluent-platform-kafka-cluster", "kafka-cluster")
cmd.MarkFlagsMutuallyExclusive("confluent-platform-kafka-cluster", "kafka-cluster")

return cmd
}

Expand All @@ -54,6 +55,12 @@
if err != nil {
return err
}
if cmd.Flags().Changed("kafka-cluster") {
kafkaClusterId, err = cmd.Flags().GetString("kafka-cluster")
if err != nil {
return err
}
}
createReq.KafkaClusterId = usmv1.PtrString(kafkaClusterId)

cloud, err := cmd.Flags().GetString("cloud")
Expand Down
2 changes: 0 additions & 2 deletions internal/usm/command_connect_cluster_describe.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Code generated by cli-terraform-generator; DO NOT EDIT.

package usm
Comment thread
FlamedHunter marked this conversation as resolved.

import (
Expand Down
4 changes: 1 addition & 3 deletions internal/usm/command_connect_cluster_list.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Code generated by cli-terraform-generator; DO NOT EDIT.

package usm

import (
Expand Down Expand Up @@ -51,7 +49,7 @@ func (c *connectClusterCommand) list(cmd *cobra.Command, _ []string) error {
out := &connectClusterOut{
ID: connectCluster.GetId(),
ConfluentPlatformConnectCluster: connectCluster.GetConfluentPlatformConnectClusterId(),
ConfluentPlatformKafkaClusterId: connectCluster.GetKafkaClusterId(),
KafkaClusterId: connectCluster.GetKafkaClusterId(),
Environment: connectCluster.Environment.GetId(),
UsmKafkaClusterId: connectCluster.GetUsmKafkaClusterId(),
Cloud: connectCluster.GetCloud(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"api_version": "usm/v1",
"cloud": "AWS",
"confluent_platform_connect_cluster_id": "connect-group-cloud",
"environment": {
"environment": "",
"id": "env-00000",
"related": "https://api.confluent.cloud/v2/environments/env-00000",
"resource_name": "https://api.confluent.cloud/organization=9bb441c4-edef-46ac-8a41-c49e44a3fd9a/environment=env-00000"
},
"id": "usmcc-cloud",
"kafka_cluster_id": "lkc-abc123",
"kind": "ConnectCluster",
"region": "us-east-1",
"usm_kafka_cluster_id": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Register a Confluent Platform Connect cluster with the ID connect-group-xyz123.
$ confluent usm connect-cluster create connect-group-xyz123 --confluent-platform-kafka-cluster 4k0R9d1GTS5tI9f4Y2xZ0Q --cloud aws --region us-east-1

Flags:
--confluent-platform-kafka-cluster string REQUIRED: The unique identifier of the metadata Kafka cluster for the Connect Cluster.
--confluent-platform-kafka-cluster string The unique identifier of the metadata Kafka cluster for the Connect Cluster.
--kafka-cluster string The unique identifier of the metadata Kafka cluster for the Connect Cluster.
--cloud string Specify the cloud provider as "aws", "azure", or "gcp".
--region string The home region of the Confluent Platform Connect cluster where the metadata should be stored. This field is optional. If provided, 'cloud' must also be provided. If neither 'cloud' nor 'region' are provided, the home region of the associated metadata Kafka cluster (identified by 'kafka_cluster_id') will be used as a fallback.
--environment string Environment ID.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "usmcc-f3a90de",
"confluent_platform_connect_cluster": "test-name",
"kafka_cluster_id": "lkc-abc123",
"usm_kafka_cluster_id": "usmkc-00000",
"environment": "env-596",
"cloud": "AWS",
"region": "us-east-1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
+--------------------------------+---------------+
| ID | usmcc-f3a90de |
| Confluent Platform Connect | test-name |
| Cluster | |
| Kafka Cluster Id | lkc-abc123 |
| USM Kafka Cluster Id | usmkc-00000 |
| Environment | env-596 |
| Cloud | AWS |
| Region | us-east-1 |
+--------------------------------+---------------+
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Error: at least one of the flags in the group [confluent-platform-kafka-cluster kafka-cluster] is required
Usage:
confluent usm connect-cluster create <confluent-platform-connect-cluster-id> [flags]

Aliases:
create, register

Examples:
Register a Confluent Platform Connect cluster with the ID connect-group-xyz123.

$ confluent usm connect-cluster create connect-group-xyz123 --confluent-platform-kafka-cluster 4k0R9d1GTS5tI9f4Y2xZ0Q --cloud aws --region us-east-1

Flags:
--confluent-platform-kafka-cluster string The unique identifier of the metadata Kafka cluster for the Connect Cluster.
--kafka-cluster string The unique identifier of the metadata Kafka cluster for the Connect Cluster.
--cloud string Specify the cloud provider as "aws", "azure", or "gcp".
--region string The home region of the Confluent Platform Connect cluster where the metadata should be stored. This field is optional. If provided, 'cloud' must also be provided. If neither 'cloud' nor 'region' are provided, the home region of the associated metadata Kafka cluster (identified by 'kafka_cluster_id') will be used as a fallback.
--environment string Environment ID.
--context string CLI context name.
-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,26 @@
Error: if any flags in the group [confluent-platform-kafka-cluster kafka-cluster] are set none of the others can be; [confluent-platform-kafka-cluster kafka-cluster] were all set
Usage:
confluent usm connect-cluster create <confluent-platform-connect-cluster-id> [flags]

Aliases:
create, register

Examples:
Register a Confluent Platform Connect cluster with the ID connect-group-xyz123.

$ confluent usm connect-cluster create connect-group-xyz123 --confluent-platform-kafka-cluster 4k0R9d1GTS5tI9f4Y2xZ0Q --cloud aws --region us-east-1

Flags:
--confluent-platform-kafka-cluster string The unique identifier of the metadata Kafka cluster for the Connect Cluster.
--kafka-cluster string The unique identifier of the metadata Kafka cluster for the Connect Cluster.
--cloud string Specify the cloud provider as "aws", "azure", or "gcp".
--region string The home region of the Confluent Platform Connect cluster where the metadata should be stored. This field is optional. If provided, 'cloud' must also be provided. If neither 'cloud' nor 'region' are provided, the home region of the associated metadata Kafka cluster (identified by 'kafka_cluster_id') will be used as a fallback.
--environment string Environment ID.
--context string CLI context name.
-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
Expand Up @@ -2,10 +2,9 @@
| ID | usmcc-f3a90de |
| Confluent Platform Connect | test-name |
| Cluster | |
| Confluent Platform Kafka | 4k0R9d1GTS5tI9f4Y2xZ0Q |
| Cluster Id | |
| Environment | env-596 |
| Kafka Cluster Id | 4k0R9d1GTS5tI9f4Y2xZ0Q |
| USM Kafka Cluster Id | usmkc-00000 |
| Environment | env-596 |
| Cloud | AWS |
| Region | us-east-1 |
+--------------------------------+------------------------+
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
| ID | usmcc-f3a90de |
| Confluent Platform Connect | test-name |
| Cluster | |
| Confluent Platform Kafka | 4k0R9d1GTS5tI9f4Y2xZ0Q |
| Cluster Id | |
| Environment | env-596 |
| Kafka Cluster Id | 4k0R9d1GTS5tI9f4Y2xZ0Q |
| USM Kafka Cluster Id | usmkc-00000 |
| Environment | env-596 |
| Cloud | AWS |
| Region | us-east-1 |
+--------------------------------+------------------------+
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "usmcc-cloud",
"confluent_platform_connect_cluster": "connect-group-cloud",
"kafka_cluster_id": "lkc-abc123",
"usm_kafka_cluster_id": "",
"environment": "env-00000",
"cloud": "AWS",
"region": "us-east-1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
id: usmcc-cloud
confluent_platform_connect_cluster: connect-group-cloud
kafka_cluster_id: lkc-abc123
usm_kafka_cluster_id: ""
environment: env-00000
cloud: AWS
region: us-east-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
+--------------------------------+---------------------+
| ID | usmcc-cloud |
| Confluent Platform Connect | connect-group-cloud |
| Cluster | |
| Kafka Cluster Id | lkc-abc123 |
| USM Kafka Cluster Id | |
| Environment | env-00000 |
| Cloud | AWS |
| Region | us-east-1 |
+--------------------------------+---------------------+
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "usmcc-f3a90de",
"confluent_platform_connect_cluster": "connect-group-xyz123",
"confluent_platform_kafka_cluster_id": "4k0R9d1GTS5tI9f4Y2xZ0Q",
"environment": "env-00000",
"kafka_cluster_id": "4k0R9d1GTS5tI9f4Y2xZ0Q",
"usm_kafka_cluster_id": "usmkc-00000",
"environment": "env-00000",
"cloud": "AWS",
"region": "us-east-1"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id: usmcc-f3a90de
confluent_platform_connect_cluster: connect-group-xyz123
confluent_platform_kafka_cluster_id: 4k0R9d1GTS5tI9f4Y2xZ0Q
environment: env-00000
kafka_cluster_id: 4k0R9d1GTS5tI9f4Y2xZ0Q
usm_kafka_cluster_id: usmkc-00000
environment: env-00000
cloud: AWS
region: us-east-1
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
| ID | usmcc-f3a90de |
| Confluent Platform Connect | connect-group-xyz123 |
| Cluster | |
| Confluent Platform Kafka | 4k0R9d1GTS5tI9f4Y2xZ0Q |
| Cluster Id | |
| Environment | env-00000 |
| Kafka Cluster Id | 4k0R9d1GTS5tI9f4Y2xZ0Q |
| USM Kafka Cluster Id | usmkc-00000 |
| Environment | env-00000 |
| Cloud | AWS |
| Region | us-east-1 |
+--------------------------------+------------------------+
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
{
"id": "usmcc-f3a90de",
"confluent_platform_connect_cluster": "connect-group-xyz123",
"confluent_platform_kafka_cluster_id": "4k0R9d1GTS5tI9f4Y2xZ0Q",
"environment": "env-00000",
"kafka_cluster_id": "4k0R9d1GTS5tI9f4Y2xZ0Q",
"usm_kafka_cluster_id": "usmkc-00000",
"environment": "env-00000",
"cloud": "AWS",
"region": "us-east-1"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- id: usmcc-f3a90de
confluent_platform_connect_cluster: connect-group-xyz123
confluent_platform_kafka_cluster_id: 4k0R9d1GTS5tI9f4Y2xZ0Q
environment: env-00000
kafka_cluster_id: 4k0R9d1GTS5tI9f4Y2xZ0Q
usm_kafka_cluster_id: usmkc-00000
environment: env-00000
cloud: AWS
region: us-east-1
8 changes: 4 additions & 4 deletions test/fixtures/output/usm/connect-cluster/list/list.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ID | Confluent Platform Connect | Confluent Platform Kafka | Environment | USM Kafka Cluster Id | Cloud | Region
| Cluster | Cluster Id | | | |
----------------+--------------------------------+--------------------------------+-------------+----------------------+-------+------------
usmcc-f3a90de | connect-group-xyz123 | 4k0R9d1GTS5tI9f4Y2xZ0Q | env-00000 | usmkc-00000 | AWS | us-east-1
ID | Confluent Platform Connect | Kafka Cluster Id | USM Kafka Cluster Id | Environment | Cloud | Region
| Cluster | | | | |
----------------+--------------------------------+------------------------+----------------------+-------------+-------+------------
usmcc-f3a90de | connect-group-xyz123 | 4k0R9d1GTS5tI9f4Y2xZ0Q | usmkc-00000 | env-00000 | AWS | us-east-1
7 changes: 5 additions & 2 deletions test/test-server/usm_connect_cluster_handler.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Code generated by cli-terraform-generator; DO NOT EDIT.

package testserver

import (
Expand Down Expand Up @@ -50,6 +48,11 @@ func handleUsmV1ConnectClustersId(t *testing.T) http.HandlerFunc {
switch id {
case "invalid":
w.WriteHeader(http.StatusNotFound)
case "usmcc-cloud":
connectCluster := readUsmV1ConnectClusterFile(t, "read_cloud_connect_cluster.json")

err := json.NewEncoder(w).Encode(&connectCluster)
require.NoError(t, err)
default:
connectCluster := readUsmV1ConnectClusterFile(t, "read_created_connect_cluster.json")

Expand Down
9 changes: 7 additions & 2 deletions test/usm_connect_cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Code generated by cli-terraform-generator; DO NOT EDIT.

package test
Comment thread
FlamedHunter marked this conversation as resolved.

func (s *CLITestSuite) TestUsmConnectClusterCreate() {
tests := []CLITest{
{args: "usm connect-cluster create test-name --confluent-platform-kafka-cluster 4k0R9d1GTS5tI9f4Y2xZ0Q", fixture: "usm/connect-cluster/create/create.golden"},
{args: "usm connect-cluster create test-name --confluent-platform-kafka-cluster 4k0R9d1GTS5tI9f4Y2xZ0Q --region us-east-1", fixture: "usm/connect-cluster/create/create-region.golden"},
{args: "usm connect-cluster create test-name --kafka-cluster lkc-abc123", fixture: "usm/connect-cluster/create/create-cloud-kafka.golden"},
{args: "usm connect-cluster create test-name --kafka-cluster lkc-abc123 -o json", fixture: "usm/connect-cluster/create/create-cloud-kafka-json.golden"},
{args: "usm connect-cluster create test-name", fixture: "usm/connect-cluster/create/create-fail-missing-kafka-flag.golden", exitCode: 1},
{args: "usm connect-cluster create test-name --confluent-platform-kafka-cluster 4k0R9d1GTS5tI9f4Y2xZ0Q --kafka-cluster lkc-abc123", fixture: "usm/connect-cluster/create/create-fail-mutually-exclusive-kafka-flags.golden", exitCode: 1},
}

for _, test := range tests {
Expand Down Expand Up @@ -33,6 +35,9 @@ func (s *CLITestSuite) TestUsmConnectClusterDescribe() {
{args: "usm connect-cluster describe usmcc-1", fixture: "usm/connect-cluster/describe/describe.golden"},
{args: "usm connect-cluster describe usmcc-1 -o json", fixture: "usm/connect-cluster/describe/describe-json.golden"},
{args: "usm connect-cluster describe usmcc-1 -o yaml", fixture: "usm/connect-cluster/describe/describe-yaml.golden"},
{args: "usm connect-cluster describe usmcc-cloud", fixture: "usm/connect-cluster/describe/describe-cloud.golden"},
{args: "usm connect-cluster describe usmcc-cloud -o json", fixture: "usm/connect-cluster/describe/describe-cloud-json.golden"},
{args: "usm connect-cluster describe usmcc-cloud -o yaml", fixture: "usm/connect-cluster/describe/describe-cloud-yaml.golden"},
{args: "usm connect-cluster describe invalid", fixture: "usm/connect-cluster/describe/describe-invalid.golden", exitCode: 1},
}

Expand Down