From c35a79953af8645b54710a25a9ae02b7ff973dbb Mon Sep 17 00:00:00 2001 From: Himanshu Singla Date: Fri, 6 Feb 2026 14:01:31 +0530 Subject: [PATCH 1/2] Add GCP suuport in connect artifact commands --- internal/connect/command_artifact_create.go | 10 +++++++--- internal/connect/command_artifact_delete.go | 2 +- internal/connect/command_artifact_describe.go | 2 +- internal/connect/command_artifact_list.go | 2 +- test/connect_test.go | 15 +++++++++++++- .../connect/artifact/create-gcp-jar.golden | 9 +++++++++ .../connect/artifact/create-gcp-zip.golden | 9 +++++++++ .../artifact/create-invalid-cloud-type.golden | 2 +- .../connect/artifact/delete-gcp-force.golden | 1 + .../connect/artifact/delete-gcp-prompt.golden | 1 + .../connect/artifact/describe-gcp-jar.golden | 9 +++++++++ .../connect/artifact/describe-gcp-json.golden | 9 +++++++++ .../connect/artifact/describe-gcp-yaml.golden | 7 +++++++ .../connect/artifact/describe-gcp-zip.golden | 9 +++++++++ .../connect/artifact/list-gcp-json.golden | 20 +++++++++++++++++++ .../connect/artifact/list-gcp-yaml.golden | 14 +++++++++++++ .../output/connect/artifact/list-gcp.golden | 4 ++++ test/test-server/connect_handler.go | 12 ++++++++--- 18 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 test/fixtures/output/connect/artifact/create-gcp-jar.golden create mode 100644 test/fixtures/output/connect/artifact/create-gcp-zip.golden create mode 100644 test/fixtures/output/connect/artifact/delete-gcp-force.golden create mode 100644 test/fixtures/output/connect/artifact/delete-gcp-prompt.golden create mode 100644 test/fixtures/output/connect/artifact/describe-gcp-jar.golden create mode 100644 test/fixtures/output/connect/artifact/describe-gcp-json.golden create mode 100644 test/fixtures/output/connect/artifact/describe-gcp-yaml.golden create mode 100644 test/fixtures/output/connect/artifact/describe-gcp-zip.golden create mode 100644 test/fixtures/output/connect/artifact/list-gcp-json.golden create mode 100644 test/fixtures/output/connect/artifact/list-gcp-yaml.golden create mode 100644 test/fixtures/output/connect/artifact/list-gcp.golden diff --git a/internal/connect/command_artifact_create.go b/internal/connect/command_artifact_create.go index 783c57d425..2aa4e0c79d 100644 --- a/internal/connect/command_artifact_create.go +++ b/internal/connect/command_artifact_create.go @@ -34,7 +34,7 @@ func (c *artifactCommand) newCreateCommand() *cobra.Command { } cmd.Flags().String("artifact-file", "", "Connect artifact JAR file or ZIP file.") - pcmd.AddCloudAwsAzureFlag(cmd) + pcmd.AddCloudFlag(cmd) pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand) cmd.Flags().String("description", "", "Specify the Connect artifact description.") pcmd.AddContextFlag(cmd, c.CLICommand) @@ -80,9 +80,9 @@ func (c *artifactCommand) createArtifact(cmd *cobra.Command, args []string) erro Environment: camv1.PtrString(environment), } - supportedClouds := []string{"aws", "azure"} + supportedClouds := []string{"aws", "azure", "gcp"} if !slices.Contains(supportedClouds, strings.ToLower(cloud)) { - return fmt.Errorf("only clouds supported are `AWS` and `AZURE`") + return fmt.Errorf("only clouds supported are `AWS`, `AZURE` and `GCP`") } resp, err := c.V2Client.GetArtifactPresignedUrl(request) @@ -94,6 +94,10 @@ func (c *artifactCommand) createArtifact(cmd *cobra.Command, args []string) erro if err := utils.UploadFileToAzureBlob(resp.GetUploadUrl(), artifactFile, strings.ToLower(resp.GetContentFormat())); err != nil { return err } + } else if strings.ToLower(cloud) == "gcp" { + if err := utils.UploadFileToGoogleCloudStorage(resp.GetUploadUrl(), artifactFile, strings.ToLower(resp.GetContentFormat())); err != nil { + return err + } } else { if err := utils.UploadFile(resp.GetUploadUrl(), artifactFile, resp.GetUploadFormData()); err != nil { return err diff --git a/internal/connect/command_artifact_delete.go b/internal/connect/command_artifact_delete.go index 5b3bbba7fe..6629e7e48a 100644 --- a/internal/connect/command_artifact_delete.go +++ b/internal/connect/command_artifact_delete.go @@ -25,7 +25,7 @@ func (c *artifactCommand) newDeleteCommand() *cobra.Command { ), } - pcmd.AddCloudAwsAzureFlag(cmd) + pcmd.AddCloudFlag(cmd) pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand) pcmd.AddContextFlag(cmd, c.CLICommand) pcmd.AddForceFlag(cmd) diff --git a/internal/connect/command_artifact_describe.go b/internal/connect/command_artifact_describe.go index 527683502c..9be4e5f00c 100644 --- a/internal/connect/command_artifact_describe.go +++ b/internal/connect/command_artifact_describe.go @@ -23,7 +23,7 @@ func (c *artifactCommand) newDescribeCommand() *cobra.Command { ), } - pcmd.AddCloudAwsAzureFlag(cmd) + pcmd.AddCloudFlag(cmd) pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand) pcmd.AddContextFlag(cmd, c.CLICommand) pcmd.AddOutputFlag(cmd) diff --git a/internal/connect/command_artifact_list.go b/internal/connect/command_artifact_list.go index b40b520ec2..37e1dc58b8 100644 --- a/internal/connect/command_artifact_list.go +++ b/internal/connect/command_artifact_list.go @@ -24,7 +24,7 @@ func (c *artifactCommand) newListCommand() *cobra.Command { ), } - pcmd.AddCloudAwsAzureFlag(cmd) + pcmd.AddCloudFlag(cmd) pcmd.AddEnvironmentFlag(cmd, c.AuthenticatedCLICommand) pcmd.AddContextFlag(cmd, c.CLICommand) pcmd.AddOutputFlag(cmd) diff --git a/test/connect_test.go b/test/connect_test.go index a52146b6fc..52203a4dfe 100644 --- a/test/connect_test.go +++ b/test/connect_test.go @@ -51,7 +51,7 @@ func (s *CLITestSuite) TestConnectArtifact() { tests := []CLITest{ {args: `connect artifact create my-connect-artifact-jar --artifact-file "test/fixtures/input/connect/artifact-example.jar" --cloud aws --environment env-123456 --description new-jar-artifact`, fixture: "connect/artifact/create-jar.golden"}, {args: `connect artifact create my-connect-artifact-zip --artifact-file "test/fixtures/input/connect/artifact-example.zip" --cloud aws --environment env-123456 --description new-zip-artifact`, fixture: "connect/artifact/create-zip.golden"}, - {args: `connect artifact create my-connect-artifact --artifact-file "test/fixtures/input/connect/artifact-example.zip" --cloud gcp --environment env-123456 --description new-invalid-artifact`, fixture: "connect/artifact/create-invalid-cloud-type.golden", exitCode: 1}, + {args: `connect artifact create my-connect-artifact --artifact-file "test/fixtures/input/connect/artifact-example.zip" --cloud invalid --environment env-123456 --description new-invalid-artifact`, fixture: "connect/artifact/create-invalid-cloud-type.golden", exitCode: 1}, {args: `connect artifact create my-connect-artifact --artifact-file "test/fixtures/input/connect/artifact-example.jpg" --cloud aws --environment env-123456 --description new-invalid-artifact`, fixture: "connect/artifact/create-invalid-file-type.golden", exitCode: 1}, {args: "connect artifact list --cloud aws --environment env-123456", fixture: "connect/artifact/list.golden"}, {args: "connect artifact list --cloud aws --environment env-123456 -o json", fixture: "connect/artifact/list-json.golden"}, @@ -76,6 +76,19 @@ func (s *CLITestSuite) TestConnectArtifact() { {args: "connect artifact describe cfa-azure-jar123 --cloud azure --environment env-123456 -o yaml", fixture: "connect/artifact/describe-azure-yaml.golden"}, {args: "connect artifact delete cfa-azure-zip123 --cloud azure --environment env-123456 --force", fixture: "connect/artifact/delete-azure-force.golden"}, {args: "connect artifact delete cfa-azure-zip123 --cloud azure --environment env-123456", input: "y\n", fixture: "connect/artifact/delete-azure-prompt.golden"}, + + // GCP tests + {args: `connect artifact create my-connect-artifact-gcp-jar --artifact-file "test/fixtures/input/connect/artifact-example.jar" --cloud gcp --environment env-123456 --description new-jar-artifact`, fixture: "connect/artifact/create-gcp-jar.golden"}, + {args: `connect artifact create my-connect-artifact-gcp-zip --artifact-file "test/fixtures/input/connect/artifact-example.zip" --cloud gcp --environment env-123456 --description new-zip-artifact`, fixture: "connect/artifact/create-gcp-zip.golden"}, + {args: "connect artifact list --cloud gcp --environment env-123456", fixture: "connect/artifact/list-gcp.golden"}, + {args: "connect artifact list --cloud gcp --environment env-123456 -o json", fixture: "connect/artifact/list-gcp-json.golden"}, + {args: "connect artifact list --cloud gcp --environment env-123456 -o yaml", fixture: "connect/artifact/list-gcp-yaml.golden"}, + {args: "connect artifact describe cfa-gcp-zip123 --cloud gcp --environment env-123456", fixture: "connect/artifact/describe-gcp-zip.golden"}, + {args: "connect artifact describe cfa-gcp-jar123 --cloud gcp --environment env-123456", fixture: "connect/artifact/describe-gcp-jar.golden"}, + {args: "connect artifact describe cfa-gcp-jar123 --cloud gcp --environment env-123456 -o json", fixture: "connect/artifact/describe-gcp-json.golden"}, + {args: "connect artifact describe cfa-gcp-jar123 --cloud gcp --environment env-123456 -o yaml", fixture: "connect/artifact/describe-gcp-yaml.golden"}, + {args: "connect artifact delete cfa-gcp-zip123 --cloud gcp --environment env-123456 --force", fixture: "connect/artifact/delete-gcp-force.golden"}, + {args: "connect artifact delete cfa-gcp-zip123 --cloud gcp --environment env-123456", input: "y\n", fixture: "connect/artifact/delete-gcp-prompt.golden"}, } for _, test := range tests { diff --git a/test/fixtures/output/connect/artifact/create-gcp-jar.golden b/test/fixtures/output/connect/artifact/create-gcp-jar.golden new file mode 100644 index 0000000000..9f5f03a0b1 --- /dev/null +++ b/test/fixtures/output/connect/artifact/create-gcp-jar.golden @@ -0,0 +1,9 @@ ++----------------+-----------------------------+ +| ID | cfa-gcp-jar123 | +| Name | my-connect-artifact-gcp-jar | +| Description | new-jar-artifact | +| Cloud | GCP | +| Environment | env-123456 | +| Content Format | JAR | +| Status | PROCESSING | ++----------------+-----------------------------+ diff --git a/test/fixtures/output/connect/artifact/create-gcp-zip.golden b/test/fixtures/output/connect/artifact/create-gcp-zip.golden new file mode 100644 index 0000000000..8a428fa4fd --- /dev/null +++ b/test/fixtures/output/connect/artifact/create-gcp-zip.golden @@ -0,0 +1,9 @@ ++----------------+-----------------------------+ +| ID | cfa-gcp-zip123 | +| Name | my-connect-artifact-gcp-zip | +| Description | new-zip-artifact | +| Cloud | GCP | +| Environment | env-123456 | +| Content Format | ZIP | +| Status | PROCESSING | ++----------------+-----------------------------+ diff --git a/test/fixtures/output/connect/artifact/create-invalid-cloud-type.golden b/test/fixtures/output/connect/artifact/create-invalid-cloud-type.golden index 63261e4e40..32c1a44282 100644 --- a/test/fixtures/output/connect/artifact/create-invalid-cloud-type.golden +++ b/test/fixtures/output/connect/artifact/create-invalid-cloud-type.golden @@ -1 +1 @@ -Error: only clouds supported are `AWS` and `AZURE` +Error: only clouds supported are `AWS`, `AZURE` and `GCP` diff --git a/test/fixtures/output/connect/artifact/delete-gcp-force.golden b/test/fixtures/output/connect/artifact/delete-gcp-force.golden new file mode 100644 index 0000000000..2b05b288f1 --- /dev/null +++ b/test/fixtures/output/connect/artifact/delete-gcp-force.golden @@ -0,0 +1 @@ +Deleted Connect Artifact "cfa-gcp-zip123". diff --git a/test/fixtures/output/connect/artifact/delete-gcp-prompt.golden b/test/fixtures/output/connect/artifact/delete-gcp-prompt.golden new file mode 100644 index 0000000000..21f78f17d8 --- /dev/null +++ b/test/fixtures/output/connect/artifact/delete-gcp-prompt.golden @@ -0,0 +1 @@ +Are you sure you want to delete Connect Artifact "cfa-gcp-zip123"? (y/n): Deleted Connect Artifact "cfa-gcp-zip123". diff --git a/test/fixtures/output/connect/artifact/describe-gcp-jar.golden b/test/fixtures/output/connect/artifact/describe-gcp-jar.golden new file mode 100644 index 0000000000..56d72721c4 --- /dev/null +++ b/test/fixtures/output/connect/artifact/describe-gcp-jar.golden @@ -0,0 +1,9 @@ ++----------------+-----------------------------+ +| ID | cfa-gcp-jar123 | +| Name | my-connect-artifact-gcp-jar | +| Description | new-jar-artifact | +| Cloud | GCP | +| Environment | env-123456 | +| Content Format | JAR | +| Status | READY | ++----------------+-----------------------------+ diff --git a/test/fixtures/output/connect/artifact/describe-gcp-json.golden b/test/fixtures/output/connect/artifact/describe-gcp-json.golden new file mode 100644 index 0000000000..e244d7f2cb --- /dev/null +++ b/test/fixtures/output/connect/artifact/describe-gcp-json.golden @@ -0,0 +1,9 @@ +{ + "id": "cfa-gcp-jar123", + "name": "my-connect-artifact-gcp-jar", + "description": "new-jar-artifact", + "cloud": "GCP", + "environment": "env-123456", + "content_format": "JAR", + "status": "READY" +} diff --git a/test/fixtures/output/connect/artifact/describe-gcp-yaml.golden b/test/fixtures/output/connect/artifact/describe-gcp-yaml.golden new file mode 100644 index 0000000000..78a8729632 --- /dev/null +++ b/test/fixtures/output/connect/artifact/describe-gcp-yaml.golden @@ -0,0 +1,7 @@ +id: cfa-gcp-jar123 +name: my-connect-artifact-gcp-jar +description: new-jar-artifact +cloud: GCP +environment: env-123456 +content_format: JAR +status: READY diff --git a/test/fixtures/output/connect/artifact/describe-gcp-zip.golden b/test/fixtures/output/connect/artifact/describe-gcp-zip.golden new file mode 100644 index 0000000000..8a428fa4fd --- /dev/null +++ b/test/fixtures/output/connect/artifact/describe-gcp-zip.golden @@ -0,0 +1,9 @@ ++----------------+-----------------------------+ +| ID | cfa-gcp-zip123 | +| Name | my-connect-artifact-gcp-zip | +| Description | new-zip-artifact | +| Cloud | GCP | +| Environment | env-123456 | +| Content Format | ZIP | +| Status | PROCESSING | ++----------------+-----------------------------+ diff --git a/test/fixtures/output/connect/artifact/list-gcp-json.golden b/test/fixtures/output/connect/artifact/list-gcp-json.golden new file mode 100644 index 0000000000..d2cfa92c8f --- /dev/null +++ b/test/fixtures/output/connect/artifact/list-gcp-json.golden @@ -0,0 +1,20 @@ +[ + { + "id": "cfa-gcp-jar123", + "name": "my-connect-artifact-gcp-jar", + "description": "new-jar-artifact", + "cloud": "GCP", + "environment": "env-123456", + "content_format": "JAR", + "status": "READY" + }, + { + "id": "cfa-gcp-zip123", + "name": "my-connect-artifact-gcp-zip", + "description": "new-zip-artifact", + "cloud": "GCP", + "environment": "env-123456", + "content_format": "ZIP", + "status": "PROCESSING" + } +] diff --git a/test/fixtures/output/connect/artifact/list-gcp-yaml.golden b/test/fixtures/output/connect/artifact/list-gcp-yaml.golden new file mode 100644 index 0000000000..1b20c4acf0 --- /dev/null +++ b/test/fixtures/output/connect/artifact/list-gcp-yaml.golden @@ -0,0 +1,14 @@ +- id: cfa-gcp-jar123 + name: my-connect-artifact-gcp-jar + description: new-jar-artifact + cloud: GCP + environment: env-123456 + content_format: JAR + status: READY +- id: cfa-gcp-zip123 + name: my-connect-artifact-gcp-zip + description: new-zip-artifact + cloud: GCP + environment: env-123456 + content_format: ZIP + status: PROCESSING diff --git a/test/fixtures/output/connect/artifact/list-gcp.golden b/test/fixtures/output/connect/artifact/list-gcp.golden new file mode 100644 index 0000000000..546060ca74 --- /dev/null +++ b/test/fixtures/output/connect/artifact/list-gcp.golden @@ -0,0 +1,4 @@ + ID | Name | Description | Cloud | Environment | Content Format | Status +-----------------+-----------------------------+------------------+-------+-------------+----------------+------------- + cfa-gcp-jar123 | my-connect-artifact-gcp-jar | new-jar-artifact | GCP | env-123456 | JAR | READY + cfa-gcp-zip123 | my-connect-artifact-gcp-zip | new-zip-artifact | GCP | env-123456 | ZIP | PROCESSING diff --git a/test/test-server/connect_handler.go b/test/test-server/connect_handler.go index 40962b192a..97f6418862 100644 --- a/test/test-server/connect_handler.go +++ b/test/test-server/connect_handler.go @@ -191,6 +191,12 @@ func handleConnectArtifacts(t *testing.T) http.HandlerFunc { case "my-connect-artifact-azure-zip": artifact.SetId("cfa-azure-zip123") artifact.Spec.SetContentFormat("ZIP") + case "my-connect-artifact-gcp-jar": + artifact.SetId("cfa-gcp-jar123") + artifact.Spec.SetContentFormat("JAR") + case "my-connect-artifact-gcp-zip": + artifact.SetId("cfa-gcp-zip123") + artifact.Spec.SetContentFormat("ZIP") } artifact.Status = &camv1.CamV1ConnectArtifactStatus{ @@ -227,7 +233,7 @@ func handleConnectArtifacts(t *testing.T) http.HandlerFunc { if cloud != "" && strings.ToUpper(artifact.Spec.GetCloud()) != cloud { continue } - if artifact.GetId() == "cfa-jar123" || artifact.GetId() == "cfa-azure-jar123" { + if artifact.GetId() == "cfa-jar123" || artifact.GetId() == "cfa-azure-jar123" || artifact.GetId() == "cfa-gcp-jar123" { artifact.Status = &camv1.CamV1ConnectArtifactStatus{ Phase: "READY", } @@ -256,7 +262,7 @@ func handleConnectArtifactId(t *testing.T) http.HandlerFunc { return } - if id == "cfa-jar123" || id == "cfa-azure-jar123" { + if id == "cfa-jar123" || id == "cfa-azure-jar123" || id == "cfa-gcp-jar123" { artifact.Status = &camv1.CamV1ConnectArtifactStatus{ Phase: "READY", } @@ -273,7 +279,7 @@ func handleConnectArtifactId(t *testing.T) http.HandlerFunc { return } - if id == "cfa-zip123" || id == "cfa-azure-zip123" { + if id == "cfa-zip123" || id == "cfa-azure-zip123" || id == "cfa-gcp-zip123" { w.WriteHeader(http.StatusNoContent) } } From 109e230ab64be1f2527fb2b10207d56aee48eb71 Mon Sep 17 00:00:00 2001 From: Himanshu Singla Date: Fri, 6 Feb 2026 14:33:15 +0530 Subject: [PATCH 2/2] Update help text golden files to include GCP --- test/fixtures/output/connect/artifact/create-help.golden | 2 +- test/fixtures/output/connect/artifact/delete-help.golden | 2 +- test/fixtures/output/connect/artifact/describe-help.golden | 2 +- test/fixtures/output/connect/artifact/list-help.golden | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/fixtures/output/connect/artifact/create-help.golden b/test/fixtures/output/connect/artifact/create-help.golden index 5aab740d82..44c9ee66dc 100644 --- a/test/fixtures/output/connect/artifact/create-help.golden +++ b/test/fixtures/output/connect/artifact/create-help.golden @@ -10,7 +10,7 @@ Create Connect artifact "my-connect-artifact". Flags: --artifact-file string REQUIRED: Connect artifact JAR file or ZIP file. - --cloud string REQUIRED: Specify the cloud provider as "aws" or "azure". + --cloud string REQUIRED: Specify the cloud provider as "aws", "azure" or "gcp". --environment string Environment ID. --description string Specify the Connect artifact description. --context string CLI context name. diff --git a/test/fixtures/output/connect/artifact/delete-help.golden b/test/fixtures/output/connect/artifact/delete-help.golden index 035c3e09e1..d8cf1922f1 100644 --- a/test/fixtures/output/connect/artifact/delete-help.golden +++ b/test/fixtures/output/connect/artifact/delete-help.golden @@ -9,7 +9,7 @@ Delete Connect artifact. $ confluent connect artifact delete cfa-abc123 --cloud aws --environment env-abc123 Flags: - --cloud string REQUIRED: Specify the cloud provider as "aws" or "azure". + --cloud string REQUIRED: Specify the cloud provider as "aws", "azure" or "gcp". --environment string Environment ID. --context string CLI context name. --force Skip the deletion confirmation prompt. diff --git a/test/fixtures/output/connect/artifact/describe-help.golden b/test/fixtures/output/connect/artifact/describe-help.golden index 7a85bc92b4..d7f9df62d0 100644 --- a/test/fixtures/output/connect/artifact/describe-help.golden +++ b/test/fixtures/output/connect/artifact/describe-help.golden @@ -9,7 +9,7 @@ Describe a Connect artifact. $ confluent connect artifact describe cfa-abc123 --cloud aws --environment env-abc123 Flags: - --cloud string REQUIRED: Specify the cloud provider as "aws" or "azure". + --cloud string REQUIRED: Specify the cloud provider as "aws", "azure" or "gcp". --environment string Environment ID. --context string CLI context name. -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") diff --git a/test/fixtures/output/connect/artifact/list-help.golden b/test/fixtures/output/connect/artifact/list-help.golden index eb2df9138d..3d5cecf44a 100644 --- a/test/fixtures/output/connect/artifact/list-help.golden +++ b/test/fixtures/output/connect/artifact/list-help.golden @@ -9,7 +9,7 @@ List Connect artifacts. $ confluent connect artifact list --cloud aws --environment env-abc123 Flags: - --cloud string REQUIRED: Specify the cloud provider as "aws" or "azure". + --cloud string REQUIRED: Specify the cloud provider as "aws", "azure" or "gcp". --environment string Environment ID. --context string CLI context name. -o, --output string Specify the output format as "human", "json", or "yaml". (default "human")