From 2b90d98b2001e25aebd547e5d8902bf89c051cd5 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Sun, 11 Dec 2022 20:44:48 +0200 Subject: [PATCH] add some init work for cert --- .../1.0.0/templates/class/_certifcate.tpl | 28 +++++++++++++ .../1.0.0/templates/lib/certificate/_cert.tpl | 39 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 library/common/1.0.0/templates/class/_certifcate.tpl create mode 100644 library/common/1.0.0/templates/lib/certificate/_cert.tpl diff --git a/library/common/1.0.0/templates/class/_certifcate.tpl b/library/common/1.0.0/templates/class/_certifcate.tpl new file mode 100644 index 0000000000..79ec8a12ed --- /dev/null +++ b/library/common/1.0.0/templates/class/_certifcate.tpl @@ -0,0 +1,28 @@ +{{- define "ix.v1.common.class.certificate" -}} + {{- $secretName := include "ix.v1.common.names.fullname" . -}} + {{- $root := .root -}} + + {{- $certName := "TODO: Get the certName" -}} + + {{- if include "ix.v1.common.certificate.exists" (dict "root" $root "certName" $certName) }} +--- +apiVersion: {{ include "ix.v1.common.capabilities.secret.apiVersion" . }} +kind: Secret +type: kubernetes.io/tls +metadata: + name: {{ printf "%s-%s" $secretName .Release.Revision }} + {{- $labels := (default dict (include "ix.v1.common.labels" $root | fromYaml)) -}} + {{- with (include "ix.v1.common.util.labels.render" (dict "root" $root "labels" $labels) | trim) }} + labels: + {{- . | nindent 4 }} + {{- end -}} + {{- $annotations := (default dict (include "ix.v1.common.annotations" $root | fromYaml)) -}} + {{- with (include "ix.v1.common.util.annotations.render" (dict "root" $root "annotations" $annotations) | trim) }} + annotations: + {{- . | nindent 4 }} + {{- end }} +data: + tls.crt: + tls.key: + {{- end -}} +{{- end -}} diff --git a/library/common/1.0.0/templates/lib/certificate/_cert.tpl b/library/common/1.0.0/templates/lib/certificate/_cert.tpl new file mode 100644 index 0000000000..a55f6789b1 --- /dev/null +++ b/library/common/1.0.0/templates/lib/certificate/_cert.tpl @@ -0,0 +1,39 @@ +{{/* +When a cert is selected in the GUI, +middleware adds it as dict in ixCertificates. +This checks that the certName exists as a key/dict. + */}} +{{- define "ix.v1.common.certificate.exists" -}} + {{- $certName := .certName -}} + {{- $root := .root -}} + + {{- hasKey $root.Values.ixCertificates (toString $certName) -}} +{{- end -}} + +{{/* +Returns the certificate +*/}} +{{- define "ix.v1.common.certificate.cert" -}} + {{- $certName := .certName -}} + {{- $root := .root -}} + {{- if (include "ix.v1.common.certificate.exists" (dict "root" $root "certName" $certName)) -}} + {{- $certificate := (get $root.Values.ixCertificates (toString $certName)) -}} + {{- $certificate.certificate -}} + {{- else -}} + {{ fail (printf "Certificate (%s) did not found." $certName) }} + {{- end -}} +{{- end -}} + +{{/* +Returns the privateKey +*/}} +{{- define "ix.v1.common.certificate.privatekey" -}} + {{- $certName := .certName -}} + {{- $root := .root -}} + {{- if (include "ix.v1.common.certificate.exists" (dict "root" $root "certName" $certName)) -}} + {{- $privateKey := (get $root.Values.ixCertificates (toString $certName)) -}} + {{- $privateKey.privatekey -}} + {{- else -}} + {{ fail (printf "Certificate (%s) did not found." $certName) }} + {{- end -}} +{{- end -}}