-
Notifications
You must be signed in to change notification settings - Fork 24
CF-1871 : Add Catalog Update Command #3304
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
Open
Paras Negi (paras-negi-flink)
wants to merge
1
commit into
main
Choose a base branch
from
CF-1871
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package flink | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| pcmd "github.com/confluentinc/cli/v4/pkg/cmd" | ||
| ) | ||
|
|
||
| func (c *command) newCatalogUpdateCommand() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "update <resourceFilePath>", | ||
| Short: "Update a Flink catalog.", | ||
| Long: "Update an existing Kafka Catalog in Confluent Platform from a resource file.", | ||
| Args: cobra.ExactArgs(1), | ||
| RunE: c.catalogUpdate, | ||
| } | ||
|
|
||
| addCmfFlagSet(cmd) | ||
| pcmd.AddOutputFlag(cmd) | ||
|
|
||
| return cmd | ||
| } | ||
|
|
||
| func (c *command) catalogUpdate(cmd *cobra.Command, args []string) error { | ||
| resourceFilePath := args[0] | ||
|
|
||
| client, err := c.GetCmfClient(cmd) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| sdkCatalog, err := readCatalogResourceFile(resourceFilePath) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| catalogName := sdkCatalog.Metadata.Name | ||
| if catalogName == "" { | ||
| return fmt.Errorf("catalog name is required: ensure the resource file contains a non-empty \"metadata.name\" field") | ||
| } | ||
|
|
||
| if err := client.UpdateCatalog(c.createContext(), catalogName, sdkCatalog); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| sdkOutputCatalog, err := client.DescribeCatalog(c.createContext(), catalogName) | ||
paras-negi-flink marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if err != nil { | ||
| return fmt.Errorf("catalog %q was updated successfully, but failed to retrieve updated details: %w", catalogName, err) | ||
| } | ||
|
|
||
| return printCatalogOutput(cmd, sdkOutputCatalog) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
test/fixtures/input/flink/catalog/update-invalid-failure.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "apiVersion": "cmf/api/v1/catalog", | ||
| "kind": "KafkaCatalog", | ||
| "metadata": { | ||
| "name": "invalid-catalog" | ||
| }, | ||
| "spec": { | ||
| "kafkaClusters": [ | ||
| { | ||
| "databaseName": "dev" | ||
| }, | ||
| { | ||
| "databaseName": "prod" | ||
| } | ||
| ] | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
test/fixtures/input/flink/catalog/update-invalid-failure.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| apiVersion: cmf/api/v1/catalog | ||
| kind: KafkaCatalog | ||
| metadata: | ||
| name: invalid-catalog | ||
| spec: | ||
| kafkaClusters: | ||
| - databaseName: dev | ||
| - databaseName: prod |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "apiVersion": "cmf/api/v1/catalog", | ||
| "kind": "KafkaCatalog", | ||
| "metadata": { | ||
| "name": "test-catalog" | ||
| }, | ||
| "spec": { | ||
| "kafkaClusters": [ | ||
| { | ||
| "databaseName": "dev" | ||
| }, | ||
| { | ||
| "databaseName": "prod" | ||
| } | ||
| ] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| apiVersion: cmf/api/v1/catalog | ||
| kind: KafkaCatalog | ||
| metadata: | ||
| name: test-catalog | ||
| spec: | ||
| kafkaClusters: | ||
| - databaseName: dev | ||
| - databaseName: prod |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/fixtures/output/flink/catalog/update-help-onprem.golden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| Update an existing Kafka Catalog in Confluent Platform from a resource file. | ||
|
|
||
| Usage: | ||
| confluent flink catalog update <resourceFilePath> [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). |
1 change: 1 addition & 0 deletions
1
test/fixtures/output/flink/catalog/update-invalid-failure.golden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Error: failed to update Kafka Catalog "invalid-catalog": The catalog name is invalid |
23 changes: 23 additions & 0 deletions
23
test/fixtures/output/flink/catalog/update-success-json.golden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "apiVersion": "", | ||
| "kind": "", | ||
|
Comment on lines
+2
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are apiVersion and kind empty? |
||
| "metadata": { | ||
| "name": "test-catalog", | ||
| "creationTimestamp": "2025-08-05 12:00:00 +0000 UTC" | ||
| }, | ||
| "spec": { | ||
| "srInstance": { | ||
| "connectionConfig": null | ||
| }, | ||
| "kafkaClusters": [ | ||
| { | ||
| "databaseName": "test-database", | ||
| "connectionConfig": null | ||
| }, | ||
| { | ||
| "databaseName": "test-database-2", | ||
| "connectionConfig": null | ||
| } | ||
| ] | ||
| } | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
test/fixtures/output/flink/catalog/update-success-yaml.golden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| apiVersion: "" | ||
| kind: "" | ||
|
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems off |
||
| metadata: | ||
| name: test-catalog | ||
| creationTimestamp: 2025-08-05 12:00:00 +0000 UTC | ||
| spec: | ||
| srInstance: | ||
| connectionConfig: {} | ||
| kafkaClusters: | ||
| - databaseName: test-database | ||
| connectionConfig: {} | ||
| - databaseName: test-database-2 | ||
| connectionConfig: {} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| +---------------+--------------------------------+ | ||
| | Creation Time | 2025-08-05 12:00:00 +0000 UTC | | ||
| | Name | test-catalog | | ||
| | Databases | test-database, test-database-2 | | ||
| +---------------+--------------------------------+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
printCatalogOutputcentralizes catalog rendering, butcatalogCreateandcatalogDescribestill contain their own (nearly identical) output formatting logic. To avoid future drift between commands, consider switching those commands to callprintCatalogOutputas well.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.
Robert Metzger (@rmetzger) Kumar Mallikarjuna (@kumar-mallikarjuna) does it make sense to touch other existing files to reduce duplication, or should we tackle that in another change ?
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.
I think it makes sense to fix this as part of this PR