kustomize
kustomize copied to clipboard
Env variables are surrounded by double quotes
Extra quotes are added when env variables are already surrounded by quotes. This issue is similar to 460 but with configMapGenerator instead of SecretGenerator
.env
SAMPLE="Sample var"
Data output
SAMPLE: '"Sample var"'
Config map generator
configMapGenerator:
- name: env-config
behavior: merge
envs:
- .env
Expected output
Env variables should be left as is
Kustomize version
{Version:kustomize/v4.5.2 GitCommit:9091919699baf1c5a5bf71b32ca73a993e98088b BuildDate:2022-02-09T23:19:28Z GoOs:darwin GoArch:amd64}
Platform
macOS/Linux
@meyerhp: This issue is currently awaiting triage.
SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted
label.
The triage/accepted
label can be added by org members by writing /triage accepted
in a comment.
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/test-infra repository.
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/stale
is applied - After 30d of inactivity since
lifecycle/stale
was applied,lifecycle/rotten
is applied - After 30d of inactivity since
lifecycle/rotten
was applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle stale
- Mark this issue or PR as rotten with
/lifecycle rotten
- Close this issue or PR with
/close
- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/stale
is applied - After 30d of inactivity since
lifecycle/stale
was applied,lifecycle/rotten
is applied - After 30d of inactivity since
lifecycle/rotten
was applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle rotten
- Close this issue or PR with
/close
- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
I'm able to reproduce this issue on my mac both with kustomize v4.5.2 and on the current master. My exact setup is similar to the above:
simple.env
SAMPLE="Sample var"
kustomization.yaml
configMapGenerator:
- name: env-config
envs:
- simple.env
producing the following output:
apiVersion: v1
data:
SAMPLE: '"Sample var"'
kind: ConfigMap
metadata:
name: env-config-hdg5tmcf2m
This is probably a bug because
- the discussion in #460 leans towards kustomize being ignorant of quotation marks
-
secretGenerator
doesn't add or remove quotes forenvs
I replicated the setup in #460. On kustomize v4.5.2 and master on mac, I have
simple.env
FOO="VAR1"
BAR="VAR2"
kustomization.yaml
secretGenerator:
- name: env-config
envs:
- simple.env
producing the following output:
apiVersion: v1
data:
BAR: IlZBUjIi # "VAR2"
FOO: IlZBUjEi # "VAR1"
kind: Secret
metadata:
name: env-config-dcbmd5dtfm
type: Opaque
/remove-lifecycle rotten
EDIT: I misread the context here.
Highly related to https://github.com/kubernetes-sigs/kustomize/issues/4570 ~~which has a different expectation for the behaviour.~~ One commenter there rightly points out that the env file isn't YAML, so a possible stance is that Kustomize ~is right to~ should retain all characters present exactly.
~~@meyerhp if you don't want the quotes, is there a particular reason for having them in the env file in the first place?~~
After going through the other issues related to quotes and env file sources, my conclusion is that the current behaviour is correct. An env file is not YAML, and as such, quotation marks in those file are interpreted as literal characters we should use (vs. in YAML where they may be indicating that a field has a string type).
kubectl create configmap --from-env-file
behaves the same way. See the examples in https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-files, in particular that allowed="true"
becomes allowed: '"true"'
.
So if you do not want Kustomize to include quotes inside the real configmap value, the solution is to omit them from the env file.
Most of the people are having the same issue, and I didn't found any good solution for this. We can have the option if a value is already in string formated, kustomize doesn't need to stringify it again.
Anybodu got the solution or its the same as it is?