Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helmfile in combination with transformers will modify JSON formatted strings and breaks the YAML file #2188

Open
pgmgb opened this issue Dec 11, 2024 · 0 comments

Comments

@pgmgb
Copy link

pgmgb commented Dec 11, 2024

We use Helmfile to render static YAML files out of Helm charts.
There, we also use transformers to manipulate some things inside the YAML's.

It seems, that Helmfile in combination with transformers somehow manipulates JSON strings inside the YAML's as seen in the example, which is from our side not intended...

Without transformers:

# helmfile.yaml
---
repositories:
  - name: kyverno
    url: https://kyverno.github.io/kyverno

releases:
  - name: "kyverno"
    chart: kyverno/kyverno
    version: 3.3.4

helmfile --file "helmfile.yaml" template --include-crds | yq e 'select(.kind == "ConfigMap" and .metadata.name == "kyverno")' -

(...)
updateRequestThreshold: "1000"
  webhooks: "\n  {\"namespaceSelector\":{\"matchExpressions\":[{\"key\":\"kubernetes.io/metadata.name\",\"operator\":\"NotIn\",\"values\":[\"kube-system\"]},{\"key\":\"kubernetes.io/metadata.name\",\"operator\":\"NotIn\",\"values\":[\"default\"]}],\"matchLabels\":null}}"
  webhookAnnotations: "{\"admissions.enforcer/disabled\":\"true\"}"
(...)

With transformers:

# helmfile.yaml
---
repositories:
  - name: kyverno
    url: https://kyverno.github.io/kyverno

releases:
  - name: "kyverno"
    chart: kyverno/kyverno
    version: 3.3.4
    transformers:
      - apiVersion: builtin
        kind: PatchTransformer
        metadata:
          name: remove-label-helm-sh-chart
        target:
          labelSelector: "helm.sh/chart"
        patch: |-
          - op: remove
            path: "/metadata/labels/helm.sh~1chart"

helmfile --file "helmfile.yaml" template --include-crds | yq e 'select(.kind == "ConfigMap" and .metadata.name == "kyverno")' -

(...)
webhookAnnotations: '{"admissions.enforcer/disabled":"true"}'
  webhooks:2-
      {"namespaceSelector":{"matchExpressions":[{"key":"kubernetes.io/metadata.name","operator":"NotIn","values":["kube-system"]},{"key":"kubernetes.io/metadata.name","operator":"NotIn","values":["default"]}],"matchLabels":null}}
kind: ConfigMap
(...)

As seen, the webhooks will change and breaks the YAML file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant