From e3270b3a81fbde09ce33f2ccdf89ed34282a7915 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Tue, 24 Dec 2024 11:48:41 +0700 Subject: [PATCH 1/2] feat: improve helm lookup fallback in case of helm template rendering Signed-off-by: Khanh Ngo --- templates/_helpers.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index f6249b399..eefe859a6 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -56,8 +56,8 @@ app: "{{ template "harbor.name" . }}" {{/* Helper for printing values from existing secrets*/}} {{- define "harbor.secretKeyHelper" -}} - {{- if and (not (empty .data)) (hasKey .data .key) }} - {{- index .data .key | b64dec -}} + {{- if and (not (empty (.data | default dict ))) (hasKey (.data | default dict ) .key) }} + {{- index (.data | default dict ) .key | b64dec -}} {{- end -}} {{- end -}} From e5d426562080ae7e0888433b17f05b7eb49a2058 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Tue, 24 Dec 2024 11:58:27 +0700 Subject: [PATCH 2/2] fix: another similar case Signed-off-by: Khanh Ngo --- templates/_helpers.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index eefe859a6..ed9863cc1 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -112,8 +112,8 @@ app: "{{ template "harbor.name" . }}" {{- define "harbor.database.rawPassword" -}} {{- if eq .Values.database.type "internal" -}} {{- $existingSecret := lookup "v1" "Secret" .Release.Namespace (include "harbor.database" .) -}} - {{- if and (not (empty $existingSecret)) (hasKey $existingSecret.data "POSTGRES_PASSWORD") -}} - {{- .Values.database.internal.password | default (index $existingSecret.data "POSTGRES_PASSWORD" | b64dec) -}} + {{- if and (not (empty $existingSecret)) (hasKey ($existingSecret.data | default dict) "POSTGRES_PASSWORD") -}} + {{- .Values.database.internal.password | default (index ($existingSecret.data | default dict) "POSTGRES_PASSWORD" | b64dec) -}} {{- else -}} {{- .Values.database.internal.password -}} {{- end -}}