Skip to content

yaml.Marshal() can not be forced to leave strings quoted #108

@spkane

Description

@spkane

Originally reported here: kubernetes-sigs/kustomize#5558

What happened?

We have a YAML string in a ConfigMap that contains a variable (e.g. ${TEST}) which will be replaced with a string AFTER running kustomize --build .

The problem is that the quotes are removed from the string by kustomize and then if that variable is replaced with something like true, the ConfigMap will be invalid since true is interpreted as a boolean value instead of a string and that is not allowed in a ConfigMap.

What did you expect to happen?

I expect kustomize to leave a quoted string quoted.

How can we reproduce it (as minimally and precisely as possible)?

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - "configmap.yaml"
# resources.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: test-object
data:
  pci: '${TEST}'

Expected output

apiVersion: v1
data:
  pci: '${TEST}'
kind: ConfigMap
metadata:
  name: test-object

Actual output

apiVersion: v1
data:
  pci: ${TEST}
kind: ConfigMap
metadata:
  name: test-object
  • Note the missing quotes. If that variable is then templated with a boolean or integer, this is a significant problem.

Kustomize version

v5.3.0

Operating system

MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions