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
10 changes: 7 additions & 3 deletions internal/connect/command_artifact_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/connect/command_artifact_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/connect/command_artifact_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/connect/command_artifact_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 14 additions & 1 deletion test/connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/output/connect/artifact/create-gcp-jar.golden
Original file line number Diff line number Diff line change
@@ -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 |
+----------------+-----------------------------+
9 changes: 9 additions & 0 deletions test/fixtures/output/connect/artifact/create-gcp-zip.golden
Original file line number Diff line number Diff line change
@@ -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 |
+----------------+-----------------------------+
2 changes: 1 addition & 1 deletion test/fixtures/output/connect/artifact/create-help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Error: only clouds supported are `AWS` and `AZURE`
Error: only clouds supported are `AWS`, `AZURE` and `GCP`
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deleted Connect Artifact "cfa-gcp-zip123".
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Are you sure you want to delete Connect Artifact "cfa-gcp-zip123"? (y/n): Deleted Connect Artifact "cfa-gcp-zip123".
2 changes: 1 addition & 1 deletion test/fixtures/output/connect/artifact/delete-help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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 |
+----------------+-----------------------------+
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 |
+----------------+-----------------------------+
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 20 additions & 0 deletions test/fixtures/output/connect/artifact/list-gcp-json.golden
Original file line number Diff line number Diff line change
@@ -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"
}
]
14 changes: 14 additions & 0 deletions test/fixtures/output/connect/artifact/list-gcp-yaml.golden
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions test/fixtures/output/connect/artifact/list-gcp.golden
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion test/fixtures/output/connect/artifact/list-help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 9 additions & 3 deletions test/test-server/connect_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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",
}
Expand Down Expand Up @@ -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",
}
Expand All @@ -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)
}
}
Expand Down