Skip to content

Commit 7f14b32

Browse files
authored
Fixes Helm reference include reference (#515)
Issue aws-controllers-k8s/community#2029 Description of changes: Fixed the reference by using `varIncludeTemplate`, so that the controller name is properly prefixed. Generated ec2 controller code before: ``` {{/* The path the shared credentials file is mounted */}} {{- define "ack-ec2-controller.aws.credentials.path" -}} {{- printf "%s/%s" (include "aws.credentials.secret_mount_path" .) .Values.aws.credentials.secretKey -}} {{- end -}} ``` Which resulted in: ``` Error: template: ec2-chart/templates/deployment.yaml:112:20: executing "ec2-chart/templates/deployment.yaml" at <include "ack-ec2-controller.aws.credentials.path" .>: error calling include: template: ec2-chart/templates/_helpers.tpl:47:20: executing "ack-ec2-controller.aws.credentials.path" at <include "aws.credentials.secret_mount_path" .>: error calling include: template: no template "aws.credentials.secret_mount_path" associated with template "gotpl" ``` After: ``` {{/* The path the shared credentials file is mounted */}} {{- define "ack-ec2-controller.aws.credentials.path" -}} {{ $secret_mount_path := include "ack-ec2-controller.aws.credentials.secret_mount_path" . }} {{- printf "%s/%s" $secret_mount_path .Values.aws.credentials.secretKey -}} {{- end -}} ``` Now the template renders correctly. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent c2165b6 commit 7f14b32

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

templates/helm/templates/_helpers.tpl.tpl

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444

4545
{{ "{{/* The path the shared credentials file is mounted */}}" }}
4646
{{ DefineTemplate "aws.credentials.path" }}
47-
{{ "{{- printf \"%s/%s\" (include \"aws.credentials.secret_mount_path\" .) .Values.aws.credentials.secretKey -}}" }}
47+
{{ VarIncludeTemplate "secret_mount_path" "aws.credentials.secret_mount_path" }}
48+
{{ "{{- printf \"%s/%s\" $secret_mount_path .Values.aws.credentials.secretKey -}}" }}
4849
{{ "{{- end -}}" }}
4950

5051
{{ "{{/* The rules a of ClusterRole or Role */}}" }}

0 commit comments

Comments
 (0)