Skip to content

CF-1872 : Add CRUD cli commands for Secrets#3305

Draft
Paras Negi (paras-negi-flink) wants to merge 2 commits intomainfrom
CF-1872
Draft

CF-1872 : Add CRUD cli commands for Secrets#3305
Paras Negi (paras-negi-flink) wants to merge 2 commits intomainfrom
CF-1872

Conversation

@paras-negi-flink
Copy link
Copy Markdown

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

Release Notes

Breaking Changes

  • None.

New Features

  • Added confluent flink secrets create|list|describe|update|delete commands to manage CMF Secrets (sensitive credentials used by Flink SQL catalogs) on Confluent Platform.

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-1872 — Manage CMF Secrets for the Confluent CLI, targeting Confluent Platform / CP Flink (CMF on-prem):

  • Adds a new command group under confluent flink:

    • confluent flink secret create <resourceFilePath>
    • confluent flink secret list
    • confluent flink secret describe <secretName>
    • confluent flink secret update <resourceFilePath>
    • confluent flink secret delete <secretName>
  • Secrets store sensitive credentials (e.g., Kafka and Schema Registry passwords) used by Flink SQL catalogs. They are referenced by catalog databases and environment secret mappings to inject credentials at statement execution time. Secret data is masked in responses for security.

  • Wires these commands to the existing CMF Secret REST APIs:

    • POST/GET/PUT/DELETE /cmf/api/v1/secrets[/{secretName}].
  • Introduces a CmfRestClient wrapper for Secret operations and corresponding local types/output formatting, following existing patterns used for catalogs, compute pools, and catalog databases.

Blast Radius

  • Scope is limited to new Flink secret commands; existing CLI behavior (including other confluent flink and confluent kafka commands) is unchanged.
  • If something goes wrong:
    • Impact is confined to users managing secrets via the new commands:
      • Secret creation/update/delete may fail or surface CMF errors.
      • Listing/describe may not show correct state for secrets.
    • 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-1872
  • 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)

Manual CLI validation

Attached in the comment below

Copilot AI review requested due to automatic review settings April 4, 2026 03:35
@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 Confluent Platform (on-prem) support in the Flink CLI for managing CMF “Secret” resources, including REST client support and integration-test coverage via the test server + golden fixtures.

Changes:

  • Introduces confluent flink secret with CRUD subcommands (create/describe/list/update/delete) and output formatting.
  • Extends the CMF REST client and the on-prem test server router/handlers to support the /cmf/api/v1/secrets endpoints.
  • Adds integration tests plus JSON/YAML input fixtures and golden outputs for the new commands.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/flink/command.go Registers the new flink secret command under Flink (on-prem).
internal/flink/command_secret*.go Implements secret command group + CRUD subcommands, file parsing, and output shaping.
internal/flink/local_types.go Adds local serializable types for secrets for JSON/YAML output.
pkg/flink/cmf_rest_client.go Adds CreateSecret/DescribeSecret/ListSecrets/UpdateSecret/DeleteSecret CMF client methods.
pkg/resource/resource.go Adds resource.FlinkSecret label used by deletion prompts/messages.
test/test-server/flink_onprem_router.go Wires new secrets routes into the on-prem test server router.
test/test-server/flink_onprem_handler.go Implements test-server handlers for secrets CRUD and list pagination behavior.
test/flink_onprem_test.go Adds integration tests for flink secret commands (including YAML input variants).
test/fixtures/input/flink/secret/* Adds JSON/YAML resource-file inputs for create/update success and failure cases.
test/fixtures/output/flink/secret/* Adds golden outputs for command results and flink secret --help (on-prem).

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

Comment on lines +31 to +35
cmd.AddCommand(c.newSecretCreateCommand())
cmd.AddCommand(c.newSecretDeleteCommand())
cmd.AddCommand(c.newSecretDescribeCommand())
cmd.AddCommand(c.newSecretListCommand())
cmd.AddCommand(c.newSecretUpdateCommand())
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

The repo’s recursive help tests generate help fixtures for every available command/subcommand. Since flink secret introduces new leaf subcommands (create/delete/describe/list/update), you’ll also need to add the corresponding *-help-onprem.golden fixtures under test/fixtures/output/flink/secret/ (e.g., create-help-onprem.golden, delete-help-onprem.golden, etc.), otherwise TestHelp will fail on on-prem runs.

Copilot uses AI. Check for mistakes.
@sonarqube-confluent
Copy link
Copy Markdown

@paras-negi-flink
Copy link
Copy Markdown
Author

  1. Create secret
parasnegi@C6V9RN9V2Y confluent_darwin_arm64_v8.0 % ./confluent flink secret create secret-create.json --url http://localhost:8080
+---------------+--------------------------+
| Creation Time | 2026-04-04T14:57:28.546Z |
| Name          | test-secret              |
**+---------------+--------------------------+**
  1. Describe Secret
parasnegi@C6V9RN9V2Y confluent_darwin_arm64_v8.0 % ./confluent flink secret describe test-secret --url http://localhost:8080 --output json
{
  "apiVersion": "cmf.confluent.io/v1",
  "kind": "Secret",
  "metadata": {
    "name": "test-secret",
    "creationTimestamp": "2026-04-04T14:57:28.546Z",
    "updateTimestamp": "2026-04-04T14:57:28.546Z",
    "uid": "91f30abc-11d6-45a6-b70f-ca0562c2a3b2",
    "labels": {},
    "annotations": {}
  },
  "spec": {},
  "status": {
    "version": "0",
    "environments": []
  }
}
  1. Describe Secret YAML
parasnegi@C6V9RN9V2Y confluent_darwin_arm64_v8.0 % ./confluent flink secret describe test-secret --url http://localhost:8080 --output yaml
apiVersion: cmf.confluent.io/v1
kind: Secret
metadata:
    name: test-secret
    creationTimestamp: "2026-04-04T14:57:28.546Z"
    updateTimestamp: "2026-04-04T14:57:28.546Z"
    uid: 91f30abc-11d6-45a6-b70f-ca0562c2a3b2
    labels: {}
    annotations: {}
spec: {}
status:
    version: "0"
    environments: []
  1. List Secrets
parasnegi@C6V9RN9V2Y confluent_darwin_arm64_v8.0 % ./confluent flink secret list --url http://localhost:8080                     
       Creation Time       |       Name        
---------------------------+-------------------
  2026-03-25T14:08:11.506Z | sec-kafka-secret  
  2026-04-04T14:57:28.546Z | test-secret 
  1. Delete Secret
parasnegi@C6V9RN9V2Y confluent_darwin_arm64_v8.0 % ./confluent flink secret delete test-secret --url http://localhost:8080              
Are you sure you want to delete Flink secret "test-secret"? (y/n): y
Deleted Flink secret "test-secret".
parasnegi@C6V9RN9V2Y confluent_darwin_arm64_v8.0 % ./confluent flink secret list --url http://localhost:8080                            
       Creation Time       |       Name        
---------------------------+-------------------
  2026-03-25T14:08:11.506Z | sec-kafka-secret

@paras-negi-flink Paras Negi (paras-negi-flink) changed the title CF-1872 : Add CRUD cli commands for Secrets Management CF-1872 : Add CRUD cli commands for Secrets Apr 5, 2026
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