diff --git a/library/common/1.0.0/templates/class/_certifcate.tpl b/library/common/1.0.0/templates/class/_certifcate.tpl index 094a9f3cd0..c5386a498e 100644 --- a/library/common/1.0.0/templates/class/_certifcate.tpl +++ b/library/common/1.0.0/templates/class/_certifcate.tpl @@ -2,9 +2,11 @@ {{- $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)) }} + {{- $certName := .certName -}} + {{- if (include "ix.v1.common.certificate.exists" (dict "root" $root "certName" $certName)) -}} + {{- if .key -}} + {{- include "ix.v1.common.certificate.get" (dict "root" $root "certName" $certName "key" "certificate") -}} + {{- else }} --- apiVersion: {{ include "ix.v1.common.capabilities.secret.apiVersion" . }} kind: Secret diff --git a/library/common/1.0.0/templates/spawner/_certificate.tpl b/library/common/1.0.0/templates/spawner/_certificate.tpl new file mode 100644 index 0000000000..99652e9506 --- /dev/null +++ b/library/common/1.0.0/templates/spawner/_certificate.tpl @@ -0,0 +1,18 @@ +{{/* +Call this from anywhere to create a Secret/k8s.tls +Pass a "root" object and the "certName" +(certName comes from Scale's GUI definitions) +If you also pass a "key" when calling this spawner, +instead of creating a secret it will return you the value +of that key (if exists) +*/}} +{{- define "ix.v1.common.spawner.certificate" -}} + {{- $certName := .certName -}} + {{- $root := .root -}} + + {{- if .key -}} + {{- include "ix.v1.common.class.certificate" (dict "root" $root "key" .key "certName" .certName) -}} + {{- else -}} + {{- include "ix.v1.common.class.certificate" (dict "root" $root "certName" .certName) -}} + {{- end -}} +{{- end -}}