Skip to content

fix: remove double base64 encoding of ConfigMap binaryData#2097

Open
Yanhu007 wants to merge 1 commit intokubernetes:mainfrom
Yanhu007:fix/configmap-double-base64
Open

fix: remove double base64 encoding of ConfigMap binaryData#2097
Yanhu007 wants to merge 1 commit intokubernetes:mainfrom
Yanhu007:fix/configmap-double-base64

Conversation

@Yanhu007
Copy link
Copy Markdown

Fixes #2082

Problem

When converting Docker Compose configs to Kubernetes ConfigMaps, binary data is manually base64-encoded before being assigned to ConfigMap.BinaryData:

binData[k] = []byte(base64.StdEncoding.EncodeToString([]byte(v)))

However, ConfigMap.BinaryData is of type map[string][]byte and 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:

binData[k] = []byte(v)

This is a one-line fix (plus removing the unused encoding/base64 import).

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
@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Apr 13, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Invalid commit message issues detected

Invalid commit messages

Keywords which can automatically close issues and hashtag(#) mentions are not allowed.

  • 0fb6508 fix: remove double base64 encoding of ConfigMap binaryData

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.

@linux-foundation-easycla
Copy link
Copy Markdown

CLA Not Signed

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Apr 13, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @Yanhu007!

It looks like this is your first PR to kubernetes/kompose 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kompose has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Yanhu007
Once this PR has been reviewed and has the lgtm label, please assign cdrage for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from TessaIO and cdrage April 13, 2026 03:36
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Double base64 encoding in configmap.yaml

2 participants