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

[bitnami/common] Template rendering is trying to call function #31503

Open
notwaf opened this issue Jan 22, 2025 · 15 comments
Open

[bitnami/common] Template rendering is trying to call function #31503

notwaf opened this issue Jan 22, 2025 · 15 comments
Assignees
Labels
common in-progress tech-issues The user has a technical issue about an application

Comments

@notwaf
Copy link

notwaf commented Jan 22, 2025

Name and Version

bitnami/common v2.29.0

What architecture are you using?

None

What steps will reproduce the bug?

  1. use these configs:
    values.yaml
configMap:
  data:
    blah: "xcbvxcvbcbv{{ `{{ASDF}}` }}iouyyiouoiyu"

configmap.yaml

{{- $allValues := include "common.tplvalues.render" ( dict "value" ( include "common.tplvalues.merge" ( dict "values" ( list $.Values .Values $ . ) "context" $ ) ) "context" $ ) | fromYaml }}
{{- with $allValues.configMap }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: blah
data:
{{ .data | toYaml | indent 2 }}
{{- end }}

2.run helm

Are you using any custom parameters or values?

No response

What is the expected behavior?

yaml should render successfully with the following output:

apiVersion: v1
kind: ConfigMap
metadata:
  name: blah
data:
  blah: "xcbvxcvbcbv{{ASDF}}iouyyiouoiyu"

What do you see instead?

template: gotpl:5: function "ASDF" not defined

Additional information

definitely could be doing something wrong, but seems odd that it breaks like this.

@notwaf notwaf added the tech-issues The user has a technical issue about an application label Jan 22, 2025
@github-actions github-actions bot added the triage Triage is needed label Jan 22, 2025
@javsalgar javsalgar changed the title template rendering is trying to call function [bitnami/common] Template rendering is trying to call function Jan 22, 2025
@javsalgar
Copy link
Contributor

Hi,

Does the issue happen with this?

    blah: "xcbvxcvbcbv{{ print "{{ASDF}}" }}iouyyiouoiyu"

@notwaf
Copy link
Author

notwaf commented Jan 22, 2025

it doesn't like the quotes, but escaping them still gives the same "not defined" error.

@notwaf
Copy link
Author

notwaf commented Jan 22, 2025

@javsalgar also tried with printf as well and same issue.

@javsalgar
Copy link
Contributor

Could you try removing the common.tplvalues.merge? I think it is being evaluated twice I would like to confirm it

@notwaf
Copy link
Author

notwaf commented Jan 23, 2025

replaced the first line with {{- $allValues := include "common.tplvalues.render" ( dict "value" .Values "context" $ ) | fromYaml }}. did not change results and still produces the same function undefined error.

@github-actions github-actions bot removed the triage Triage is needed label Jan 24, 2025
@github-actions github-actions bot assigned dgomezleon and unassigned javsalgar Jan 24, 2025
@notwaf
Copy link
Author

notwaf commented Jan 25, 2025

don't remember this issue happening a few version ago. wondering if it is because of https://github.com/bitnami/charts/blob/main/bitnami/common/templates/_tplvalues.tpl#L15

@notwaf
Copy link
Author

notwaf commented Jan 27, 2025

@dgomezleon @javsalgar any updates here? we are basically blocked on this issue. not sure if there is a work-around for this?

@dgomezleon
Copy link
Member

Hi @notwaf ,

Would this work for you?

  • configmap.yaml
{{- $allValues := include "common.tplvalues.render" ( dict "value" ( include "common.tplvalues.merge" ( dict "values" ( list $.Values .Values $ . ) "context" $ ) ) "context" $ ) | fromYaml }}
{{- with $allValues.configMap }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: blah
data:
{{ .data | toYaml | replace "{{`" "{{"| replace "`}}" "}}" | indent 2 }}
{{- end }}
  • values.yaml
configMap:
  data:
    blah: "xcbvxcvbcbv{{`ASDF`}}iouyyiouoiyu"

It produces the expected output for me.

@notwaf
Copy link
Author

notwaf commented Jan 28, 2025

nope, no change. still produces the "function undefined" error for me

@javsalgar
Copy link
Contributor

javsalgar commented Jan 29, 2025

Hi,

I tried this and it worked without issues

configmap.yaml

kind: ConfigMap
metadata:
  name: blah
data:  {{- include "common.tplvalues.render" (dict "value" .Values.configMap "context" $) | nindent 2 }}

values.yaml

configMap:
  data:
    blah: "xcbvxcvbcbv{{ `{{ASDF}}` }}iouyyiouoiyu"

This provided the expected output

# Source: kafka/templates/sample.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: blah
data:
  data:
    blah: xcbvxcvbcbv{{ASDF}}iouyyiouoiyu

@notwaf
Copy link
Author

notwaf commented Jan 29, 2025

yep, that does work if there is only a single config map manifest file. is the merge not needed to merge many different included values.yaml files together?

we have many other k8s manifests that use the render and merge templates. it still produces the same "undefined function" error.

@javsalgar
Copy link
Contributor

Let me see if I understand it correctly, could you explain in more detail what you want to achieve, and how the values would look like?

Is it that you want the configMap section to be an array? Could you please provide a more thorough example that justifies the need to use tplValues.merge

@notwaf
Copy link
Author

notwaf commented Jan 30, 2025

do realise that i forgot to mention that we use helmfile. the helmfile includes all of these values files:

---
releases:
  - name: blah
    namespace: blah
    chart: ../the-chart
    values:
      - base.yaml
      - ../../environments/{{ .Environment.Name }}.yaml
      - {{ .Environment.Name }}.yaml

the existing yaml files are still good, with a few additions:
../../environments/env.yaml
same as env/base.yaml and could have more values to merge

env.yaml

configMap:
  data:
    blah: "xcbvxcvbcbv{{ `{{ASDF}}` }}iouyyiouoiyu"

base.yaml

configMap:
  data:
    foo: iouyyiouoiyu
    merge: together

@dgomezleon
Copy link
Member

I was able to make it work like this:

  • Change from
blah: "xcbvxcvbcbv{{ `{{ASDF}}` }}iouyyiouoiyu"

to

blah: "xcbvxcvbcbv{`{ASDF}`}iouyyiouoiyu"

And using

{{- $allValues := include "common.tplvalues.render" ( dict "value" ( include "common.tplvalues.merge" ( dict "values" ( list $.Values .Values $ . ) "context" $ ) ) "context" $ ) | fromYaml }}
{{- with $allValues.configMap }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: blah
data:
{{ .data | toYaml | replace "{`{" "{{"| replace "}`}" "}}" | indent 2 }}
{{- end }}

It produces the correct output for me:

$ helm template chart .
---
# Source: MyChart/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: blah
data:
  blah: xcbvxcvbcbv{{ASDF}}iouyyiouoiyu

@notwaf
Copy link
Author

notwaf commented Feb 3, 2025

woot, that works for me as well. is this a bug in the rendering/common chart itself? or is this the expected behavior of how it is supposed to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common in-progress tech-issues The user has a technical issue about an application
Projects
None yet
Development

No branches or pull requests

3 participants