fluxcd / flux2

Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit.
https://fluxcd.io
Apache License 2.0
6.55k stars 606 forks source link

Generated secrets contain newline #3463

Open mjroeleveld opened 1 year ago

mjroeleveld commented 1 year ago

Describe the bug

Kubernetes secrets generated by secretGenerator contain newlines.

Steps to reproduce

sops secrets/test

Save it without any newline.

Add a kustomization with the following:

secretGenerator:
  - files:
      - secrets/test
    name: test-secret

The Kubernetes secret contains a newline:

image

Expected behavior

The secret should not contain a newline.

Screenshots and recordings

No response

OS / Distro

Amazon EKS optimized Amazon Linux AMIs

Flux version

0.38.2

Flux check

N/A

Git provider

No response

Container Registry provider

No response

Additional context

No response

Code of Conduct

kr-jmd commented 1 year ago

Also seeing this issue...does anyone have a workaround or fix?

mjroeleveld commented 1 year ago

My workaround was to use env files for single-line secrets.

makkes commented 1 year ago

Are you sure there's no newline in your input file? Most editors append a newline at the end of a line so even if in e.g. VIM you don't see a newline, it's actually there.

mjroeleveld commented 1 year ago

The tests of the kustomize-controller actually check for this newline, too.

kkerennnn commented 8 months ago

I had trouble editing the file properly via every IDE, I then clone my git repo to VS and was finally able to remove the newline