Skip to content

CF-1871 : Add Catalog Update Command#3304

Open
Paras Negi (paras-negi-flink) wants to merge 1 commit intomainfrom
CF-1871
Open

CF-1871 : Add Catalog Update Command#3304
Paras Negi (paras-negi-flink) wants to merge 1 commit intomainfrom
CF-1871

Conversation

@paras-negi-flink
Copy link
Copy Markdown

@paras-negi-flink Paras Negi (paras-negi-flink) commented Apr 3, 2026

Release Notes

Breaking Changes

  • None

New Features

  • PLACEHOLDER

Bug Fixes

  • None

Checklist

  • I have successfully built and used a custom CLI binary, without linter issues from this PR.
  • I have clearly specified in the What section below whether this PR applies to Confluent Cloud, Confluent Platform, or both.
  • I have verified this PR in Confluent Cloud pre-prod or production environment, if applicable.
  • I have verified this PR in Confluent Platform on-premises environment, if applicable.
  • I have attached manual CLI verification results or screenshots in the Test & Review section below.
  • I have added appropriate CLI integration or unit tests for any new or updated commands and functionality.
  • I confirm that this PR introduces no breaking changes or backward compatibility issues.
  • I have indicated the potential customer impact if something goes wrong in the Blast Radius section below.
  • I have put checkmarks below confirming that the feature associated with this PR is enabled in:
    • Confluent Cloud prod
    • Confluent Cloud stag
    • Confluent Platform
    • Check this box if the feature is enabled for certain organizations only

What

This PR implements CF-1871 — CLI: Update SQL catalog for the Confluent CLI, targeting Confluent Platform / CP Flink (CMF on-prem):

  • Adds a new command group under confluent flink catalog:

    • confluent flink catalog update <resourceFilePath>
  • Wires this command to the existing CMF Catalog REST APIs:

  • PUT /cmf/api/v1/catalogs/kafka/{catName}.

  • Updates CmfRestClient wrapper for Catalog operations and corresponding local types/output formatting, following existing patterns used for catalogs and compute pools.

Blast Radius

  • Scope is limited to new Flink catalog update command; existing CLI behavior (including other confluent flink and confluent kafka commands) is unchanged.
  • If something goes wrong:
    • Impact is confined to users updating Kafka Catalog via the new command:
      • Catalog update may fail or surface CMF errors.
      • Catalog update may not show correct state for databases.
    • No changes are made to Flyway migrations or catalog persistence; CMF remains the source of truth.
  • There are no breaking changes to existing commands, flags, or APIs. Removing or reverting this feature is straightforward (command group + client wrapper).

References

Test & Review

Environment

  • Repo: confluentinc/cli
  • Branch: CF-1871
  • CMF: 2.3-SNAPSHOT (image: confluentinc/cp-cmf:c505ee8b) - Kubernetes: local cluster with CMF deployed (cmf-service exposed via kubectl port-forward svc/cmf-service 8080:80 -n e2e)
parasnegi@C6V9RN9V2Y confluent_darwin_arm64_v8.0 % ./confluent flink catalog describe new-kcat --url http://localhost:8080 --output json
{
  "apiVersion": "cmf.confluent.io/v1",
  "kind": "KafkaCatalog",
  "metadata": {
    "name": "new-kcat",
    "creationTimestamp": "2026-04-03T14:46:29.297Z",
    "uid": "41acaae2-62f0-4d00-a8db-4235701ac37e",
    "labels": {},
    "annotations": {}
  },
  "spec": {
    "srInstance": {
      "connectionConfig": {
        "url": "http://localhost:8081"
      }
    },
    "kafkaClusters": []
  }
}
parasnegi@C6V9RN9V2Y confluent_darwin_arm64_v8.0 % ./confluent flink catalog update create-catalog.json --url http://localhost:8080 
+---------------+--------------------------+
| Creation Time | 2026-04-03T14:46:29.297Z |
| Name          | new-kcat                 |
| Databases     |                          |
+---------------+--------------------------+
parasnegi@C6V9RN9V2Y confluent_darwin_arm64_v8.0 % ./confluent flink catalog describe new-kcat --url http://localhost:8080 --output json
{
  "apiVersion": "cmf.confluent.io/v1",
  "kind": "KafkaCatalog",
  "metadata": {
    "name": "new-kcat",
    "creationTimestamp": "2026-04-03T14:46:29.297Z",
    "uid": "41acaae2-62f0-4d00-a8db-4235701ac37e",
    "labels": {},
    "annotations": {}
  },
  "spec": {
    "srInstance": {
      "connectionConfig": {
        "url": "http://localhost:8082"
      }
    },
    "kafkaClusters": []
  }
}

Non-empty KafkaCatalog.spec.kafkaClusters is resricted owing to the Flyway Migration

parasnegi@C6V9RN9V2Y confluent_darwin_arm64_v8.0 % ./confluent flink catalog update update-catalog.json --url http://localhost:8080 
Error: failed to update Kafka Catalog "kcat": {"errors":[{"message":"Catalog 'kcat' not updated. Please do not configure kafkaClusters in the Catalog spec to specify Kafka-backed databases. This field is no longer supported. Use the dedicated KafkaDatabase resource instead."}]}

Copilot AI review requested due to automatic review settings April 3, 2026 09:01
@confluent-cla-assistant
Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for updating CMF Kafka Catalogs via the confluent flink catalog update command (Confluent Platform/on-prem), including REST client support and integration test coverage with golden fixtures.

Changes:

  • Introduces flink catalog update <resourceFilePath> command (JSON/YAML resource file) and shared catalog output formatting.
  • Adds CMF REST client support for updating Kafka catalogs and extends the on-prem test server to handle PUT requests.
  • Adds on-prem integration tests plus input/output fixtures and help goldens for the new command.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/flink/command_catalog.go Registers the new update subcommand; adds helpers for printing catalog output and reading JSON/YAML resource files.
internal/flink/command_catalog_update.go Implements the flink catalog update command behavior (read file → update → describe → print).
pkg/flink/cmf_rest_client.go Adds UpdateCatalog wrapper around the CMF SDK update endpoint with CLI-friendly error wrapping.
test/test-server/flink_onprem_handler.go Extends the CMF catalog handler to support PUT for update scenarios.
test/flink_onprem_test.go Adds integration test cases for catalog update (JSON + YAML).
test/fixtures/input/flink/catalog/* Adds JSON/YAML resource files for update success and failure cases.
test/fixtures/output/flink/catalog/* Adds golden outputs for update (human/json/yaml), update failure, and update help; updates catalog help to include update.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +62
func printCatalogOutput(cmd *cobra.Command, sdkOutputCatalog cmfsdk.KafkaCatalog) error {
if output.GetFormat(cmd) == output.Human {
table := output.NewTable(cmd)
databases := make([]string, 0, len(sdkOutputCatalog.Spec.GetKafkaClusters()))
for _, kafkaCluster := range sdkOutputCatalog.Spec.GetKafkaClusters() {
databases = append(databases, kafkaCluster.DatabaseName)
}
var creationTime string
if sdkOutputCatalog.GetMetadata().CreationTimestamp != nil {
creationTime = *sdkOutputCatalog.GetMetadata().CreationTimestamp
}
table.Add(&catalogOut{
CreationTime: creationTime,
Name: sdkOutputCatalog.GetMetadata().Name,
Databases: databases,
})
return table.Print()
}

localCatalog := convertSdkCatalogToLocalCatalog(sdkOutputCatalog)
return output.SerializedOutput(cmd, localCatalog)
}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printCatalogOutput centralizes catalog rendering, but catalogCreate and catalogDescribe still contain their own (nearly identical) output formatting logic. To avoid future drift between commands, consider switching those commands to call printCatalogOutput as well.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

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 ?

@sonarqube-confluent
Copy link
Copy Markdown

@paras-negi-flink Paras Negi (paras-negi-flink) changed the title Add Catalog Update Command CF-1871 : Add Catalog Update Command Apr 3, 2026
@paras-negi-flink Paras Negi (paras-negi-flink) marked this pull request as ready for review April 3, 2026 14:41
@paras-negi-flink Paras Negi (paras-negi-flink) requested a review from a team as a code owner April 3, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants