From 736f709ec473a3f4dc166d12a50c8feff6041cea Mon Sep 17 00:00:00 2001 From: Shijun Wang Date: Mon, 10 Jun 2024 16:22:54 +0300 Subject: [PATCH] Use helper for secret checksum calculation --- charts/pgcat/templates/_helpers.tpl | 10 ++++++++++ charts/pgcat/templates/deployment.yaml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/charts/pgcat/templates/_helpers.tpl b/charts/pgcat/templates/_helpers.tpl index 07c2d25f..c7055952 100644 --- a/charts/pgcat/templates/_helpers.tpl +++ b/charts/pgcat/templates/_helpers.tpl @@ -60,3 +60,13 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Generate a checksum of the specified template file. +*/}} +{{- define "pgcat.checksum" -}} +{{- $files := .Files -}} +{{- $secretPath := (print $.Template.BasePath "/secret.yaml") -}} +{{- $secret := $files.Get $secretPath -}} +{{- sha256sum $secret -}} +{{- end }} \ No newline at end of file diff --git a/charts/pgcat/templates/deployment.yaml b/charts/pgcat/templates/deployment.yaml index 84c57f1b..3dbd9254 100644 --- a/charts/pgcat/templates/deployment.yaml +++ b/charts/pgcat/templates/deployment.yaml @@ -12,7 +12,7 @@ spec: template: metadata: annotations: - checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + checksum/secret: {{ include "pgcat.checksum" . }} {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }}