From 0a08a94bb1b55645656579c422de5bd8922baf25 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Mon, 12 Dec 2022 19:46:32 +0200 Subject: [PATCH] update certs and add todo note --- .../1.0.0/templates/class/_certifcate.tpl | 4 ++-- .../1.0.0/templates/lib/certificate/_cert.tpl | 20 +++++++++++-------- .../templates/lib/container/_env_vars.tpl | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/library/common/1.0.0/templates/class/_certifcate.tpl b/library/common/1.0.0/templates/class/_certifcate.tpl index 6f7381e4a5..d0c916877e 100644 --- a/library/common/1.0.0/templates/class/_certifcate.tpl +++ b/library/common/1.0.0/templates/class/_certifcate.tpl @@ -2,9 +2,9 @@ {{- $cert := .cert -}} {{- $root := .root -}} - {{- if not (hasKey $cert "id") -}} + {{- if not (hasKey $cert "id") -}} {{/* This is something that should not happen when using this library */}} {{- fail (printf "Certificate (%s) has no key" $cert.nameOverride) -}} - {{- end -}} + {{- end -}} {{/* It can only happen when consuing this function within this library */}} {{- $certID := (toString $cert.id) -}} {{- if (include "ix.v1.common.certificate.exists" (dict "root" $root "certID" $certID)) -}} diff --git a/library/common/1.0.0/templates/lib/certificate/_cert.tpl b/library/common/1.0.0/templates/lib/certificate/_cert.tpl index b0b36a27c0..6ac1caea4a 100644 --- a/library/common/1.0.0/templates/lib/certificate/_cert.tpl +++ b/library/common/1.0.0/templates/lib/certificate/_cert.tpl @@ -30,9 +30,9 @@ Example keys (certificate, privatekey, expired, revoked) {{- $useRevoked := $root.Values.global.defaults.useRevokedCerts -}} {{- $useExpired := $root.Values.global.defaults.useExpiredCerts -}} - {{- if not $key -}} + {{- if not $key -}} {{/* This is something that should not happen when using this library */}} {{- fail "You need to provide a when calling this template (certificate.get)" -}} - {{- end -}} + {{- end -}} {{/* It can only happen when consuing this function within this library */}} {{- if eq (include "ix.v1.common.certificate.exists" (dict "root" $root "certID" $certID)) "true" -}} {{- $certificate := (get $root.Values.ixCertificates (toString $certID)) -}} @@ -46,22 +46,26 @@ Example keys (certificate, privatekey, expired, revoked) {{- end -}} {{- if (hasKey $certificate "revoked") -}} - {{- if and (not $useRevoked) (eq (get $certificate "revoked") true) -}} - {{- fail (printf "Certificate (%s) has been revoked" $certID) -}} + {{- if (eq (get $certificate "revoked") true) -}} + {{- if not $useRevoked -}} + {{- fail (printf "Certificate (%s) has been revoked" $certID) -}} + {{- end -}} {{- end -}} {{- end -}} {{- if (hasKey $certificate "expired") -}} - {{- if and (not $useExpired) (eq (get $certificate "expired") true) -}} - {{- fail (printf "Certificate (%s) is expired" $certID) -}} + {{- if (eq (get $certificate "expired") true) -}} + {{- if not $useExpired -}} + {{- fail (printf "Certificate (%s) is expired" $certID) -}} + {{- end -}} {{- end -}} {{- end -}} {{- if (hasKey $certificate $key) -}} {{- get $certificate $key -}} - {{- else -}} + {{- else -}} {{/* This is something that should not happen when using this library */}} {{- fail (printf "Key (%s) does not exist in certificate (%s)" $key $certID) -}} - {{- end -}} + {{- end -}} {{/* It can only happen when consuing this function within this library */}} {{- else -}} {{- fail (printf "Certificate (%s) was not found." $certID) -}} diff --git a/library/common/1.0.0/templates/lib/container/_env_vars.tpl b/library/common/1.0.0/templates/lib/container/_env_vars.tpl index c3e47f7531..a519abf2fb 100644 --- a/library/common/1.0.0/templates/lib/container/_env_vars.tpl +++ b/library/common/1.0.0/templates/lib/container/_env_vars.tpl @@ -14,7 +14,7 @@ That's why the custom dict is expected. {{- include "ix.v1.common.container.fixedEnvs" $root | trim -}} {{- end -}} {{/* Finish fixedEnv */}} {{- with $envs -}} -{{- range $k, $v := . -}} +{{- range $k, $v := . -}} {{/* TODO: Check if there is a user provided env that exist in fixedEnv and error out */}} {{- $name := $k -}} {{- $value := $v -}} {{- if kindIs "int" $name -}}