feat(secret): add binary data support#406
Open
freeznet wants to merge 3 commits into
Open
Conversation
Contributor
|
@freeznet:Thanks for your contribution. For this PR, do we need to update docs? |
Contributor
There was a problem hiding this comment.
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.binaryDataandsecretRef.binaryDataKeysAPI/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
secretRefbinary data only whenspec.binaryDatais 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 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 on lines
+243
to
+244
| secretCR.Spec.BinaryData = resolvedBinaryData | ||
| updateLocalCR = true |
| | `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. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
(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
(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:)
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)