diff --git a/examples/chart/teleport-kube-agent/templates/_helpers.tpl b/examples/chart/teleport-kube-agent/templates/_helpers.tpl index 8827f3454912e..3e00e271bf9a7 100644 --- a/examples/chart/teleport-kube-agent/templates/_helpers.tpl +++ b/examples/chart/teleport-kube-agent/templates/_helpers.tpl @@ -22,7 +22,11 @@ Create the name of the service account to use for the post-delete hook if serviceAccount is not defined or serviceAccount.name is empty, use .Release.Name-delete-hook */}} {{- define "teleport-kube-agent.deleteHookServiceAccountName" -}} -{{- coalesce .Values.serviceAccount.name .Values.serviceAccountName (printf "%s-delete-hook" .Release.Name) -}} +{{- if .Values.serviceAccount.create -}} +{{- printf "%s-delete-hook" (include "teleport-kube-agent.serviceAccountName" . ) -}} +{{- else -}} +{{- (include "teleport-kube-agent.serviceAccountName" . ) -}} +{{- end -}} {{- end -}} {{- define "teleport-kube-agent.version" -}} diff --git a/examples/chart/teleport-kube-agent/tests/job_test.yaml b/examples/chart/teleport-kube-agent/tests/job_test.yaml index 997dc79267085..2162d78018c60 100644 --- a/examples/chart/teleport-kube-agent/tests/job_test.yaml +++ b/examples/chart/teleport-kube-agent/tests/job_test.yaml @@ -96,7 +96,7 @@ tests: apiVersion: v1 - equal: path: metadata.name - value: lint-serviceaccount + value: lint-serviceaccount-delete-hook - it: should create Role for post-delete hook by default template: delete_hook.yaml