Repository navigation
Conversation
…Data Signed-off-by: YuMin Kim <yuminkim.dev@gmail.com>
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.
Closes #445
What
When a
SecretTemplateuses an input resource of kindSecretinsidestringData, the value read from.datais the base64 text stored in the Secret. It was copied intostringDataas is, and Kubernetes then base64 encoded it a second time when storing the generated Secret.dataalready decodes input values (evaluateBytes), so onlystringDatawas affected.This adds
evaluateStringData, which evaluatesstringDataagainst input values in which the.dataof every input Secret (apiVersion: v1,kind: Secret) is base64 decoded. It builds on theevaluateStringDatasuggestion in the review of the earlier attempt (#446). Other input kinds (for example aConfigMap) and other Secret fields such as.metadata.nameare unchanged. Annotations, labels andtypeare not changed.A test case is added to
Test_SecretTemplate: before the change it fails withprefix-dmFsdWUx-suffix(the base64 text ofvalue1), after the change it passes withprefix-value1-suffix.docs/secret-template.mdgets one line saying that input Secret.datais decoded instringData.Compatibility
This is a behavior change.
docs/secret-template.mddescribedstringDataas "data that is not base64 encoded", and until now$(.secret.data.key)instringDataproduced the raw base64 text. Anyone who relied on that (for example, deliberately wanting the base64 text of a Secret value insidestringData) will now get the decoded value instead, and their generated Secret will change on the next reconcile. I kept the change as narrow as I could: only.dataof input resources that are Secrets is decoded, and nothing else. I did not add an opt-out or a new syntax; if you would prefer one, I am happy to rework this.If an input Secret has a
.datavalue that is not valid base64,stringDataevaluation now fails withfailed decoding base64 from a Secret, the same errordataalready returns. A Secret read through the Kubernetes API always has valid base64 there, so I do not expect this in practice.Testing
go test ./pkg/...passes.golangci-lintlocally (the pinned version is not installed here);gofmtreports nothing.