Skip to content

feat(secret): add binary data support#406

Open
freeznet wants to merge 3 commits into
mainfrom
freeznet/binary-secret-support
Open

feat(secret): add binary data support#406
freeznet wants to merge 3 commits into
mainfrom
freeznet/binary-secret-support

Conversation

@freeznet
Copy link
Copy Markdown
Member

(If this PR fixes a github issue, please add Fixes #<xyz>.)

Fixes #

(or if this PR is one task of a github issue, please add Master Issue: #<xyz> to link to the master issue.)

Master Issue: #

Motivation

Explain here the context, and why you're making that change. What is the problem you're trying to solve.

Modifications

Describe the modifications you've done.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Documentation

Check the box below.

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

@freeznet freeznet self-assigned this May 18, 2026
@freeznet freeznet requested a review from a team as a code owner May 18, 2026 14:45
Copilot AI review requested due to automatic review settings May 18, 2026 14:45
@freeznet freeznet requested a review from a team as a code owner May 18, 2026 14:45
@github-actions
Copy link
Copy Markdown
Contributor

@freeznet:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@github-actions github-actions Bot added the doc-info-missing This pr needs to mark a document option in description label May 18, 2026
Copy link
Copy Markdown
Contributor

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 binary secret data support for StreamNative Cloud Secret resources, including API fields, controller resolution from Kubernetes Secret references, cloud client payload conversion, CRDs, docs, samples, and tests.

Changes:

  • Added spec.binaryData and secretRef.binaryDataKeys API/CRD support.
  • Updated reconciliation and cloud client conversion to include binary data.
  • Added tests and documentation/examples for direct and referenced binary secret data.

Reviewed changes

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

Show a summary per file
File Description
.gitignore Ignores local PLAN.md.
api/v1alpha1/secret_types.go Adds local Secret API fields for binary data and referenced binary keys.
api/v1alpha1/zz_generated.deepcopy.go Updates deepcopy generation for new fields.
charts/pulsar-resources-operator/crds/resource.streamnative.io_secrets.yaml Mirrors CRD schema changes in Helm chart.
config/crd/bases/resource.streamnative.io_secrets.yaml Adds CRD schema for binary data fields.
config/samples/resource_v1alpha1_secret.yaml Adds sample binaryData usage.
controllers/secret_controller.go Resolves referenced binary keys and validates duplicate direct keys.
controllers/secret_controller_test.go Adds controller unit tests for referenced binary data handling.
docs/secret.md Documents binaryData and binaryDataKeys usage.
pkg/streamnativecloud/apis/cloud/v1alpha1/secret_types.go Adds cloud Secret binaryData field.
pkg/streamnativecloud/apis/cloud/v1alpha1/zz_generated.deepcopy.go Updates deepcopy generation for cloud binaryData.
pkg/streamnativecloud/secret_client.go Sends binaryData to the cloud API.
pkg/streamnativecloud/secret_client_test.go Adds cloud client payload tests for binaryData.
Files not reviewed (2)
  • api/v1alpha1/zz_generated.deepcopy.go: Language not supported
  • pkg/streamnativecloud/apis/cloud/v1alpha1/zz_generated.deepcopy.go: Language not supported
Comments suppressed due to low confidence (1)

controllers/secret_controller.go:244

  • Persisting resolved secretRef binary data only when spec.binaryData is empty makes referenced binary secrets stale after the first sync. Once this field is populated, later rotations of the referenced Kubernetes Secret resolve new bytes but are skipped here, so the cloud update continues using the old binaryData stored in the CR.
		if len(secretCR.Spec.BinaryData) == 0 && len(resolvedBinaryData) > 0 { // Only populate from SecretRef if direct binaryData is not set
			secretCR.Spec.BinaryData = resolvedBinaryData
			updateLocalCR = true

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

Comment thread controllers/secret_controller.go Outdated
Comment on lines +239 to +244
secretCR.Spec.Data = resolvedData
updateLocalCR = true
}
if len(secretCR.Spec.BinaryData) == 0 && len(resolvedBinaryData) > 0 { // Only populate from SecretRef if direct binaryData is not set
secretCR.Spec.BinaryData = resolvedBinaryData
updateLocalCR = true
Comment thread controllers/secret_controller.go Outdated
Comment on lines +243 to +244
secretCR.Spec.BinaryData = resolvedBinaryData
updateLocalCR = true
Comment thread docs/secret.md Outdated
| `type` | Used to facilitate programmatic handling of secret data | No |

*Note: Either `data` or `secretRef` must be specified.
*Note: Specify at least one of `data`, `binaryData`, or `secretRef`.
Data map[string]string `json:"data,omitempty"`

// SecretRef is the reference to the kubernetes secret
// BinaryData contains binary secret data. Values must be base64-encoded raw bytes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-info-missing This pr needs to mark a document option in description

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants