mirror of
https://github.com/truenas/charts.git
synced 2026-06-17 07:27:44 +08:00
add some init work for cert
This commit is contained in:
28
library/common/1.0.0/templates/class/_certifcate.tpl
Normal file
28
library/common/1.0.0/templates/class/_certifcate.tpl
Normal file
@@ -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 -}}
|
||||
39
library/common/1.0.0/templates/lib/certificate/_cert.tpl
Normal file
39
library/common/1.0.0/templates/lib/certificate/_cert.tpl
Normal file
@@ -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 -}}
|
||||
Reference in New Issue
Block a user