fix: remove double base64 encoding of ConfigMap binaryData#2097
fix: remove double base64 encoding of ConfigMap binaryData#2097Yanhu007 wants to merge 1 commit intokubernetes:mainfrom
Conversation
ConfigMap.BinaryData expects raw []byte values. Kubernetes handles base64 encoding during YAML/JSON serialization. The current code manually base64 encodes the data before assigning it, causing double encoding — the serialized output contains base64-of-base64. Remove the manual base64.StdEncoding.EncodeToString call and pass raw bytes directly. Fixes kubernetes#2082
|
Invalid commit message issues detected Invalid commit messagesKeywords which can automatically close issues and hashtag(#) mentions are not allowed.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
|
Welcome @Yanhu007! |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Yanhu007 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Fixes #2082
Problem
When converting Docker Compose configs to Kubernetes ConfigMaps, binary data is manually base64-encoded before being assigned to
ConfigMap.BinaryData:However,
ConfigMap.BinaryDatais of typemap[string][]byteand Kubernetes automatically base64-encodes the raw bytes during YAML/JSON serialization. This results in double base64 encoding — decoding once yields another base64 string instead of the original binary data.Fix
Remove the manual
base64.StdEncoding.EncodeToString()call and pass raw bytes directly:This is a one-line fix (plus removing the unused
encoding/base64import).