mirror of
https://github.com/truenas/charts.git
synced 2026-06-18 01:26:53 +08:00
extract more names
This commit is contained in:
@@ -5,11 +5,7 @@
|
||||
{{- $root := .root -}}
|
||||
{{- $defaultServiceType := $root.Values.global.defaults.serviceType -}}
|
||||
{{- $defaultPortProtocol := $root.Values.global.defaults.portProtocol -}}
|
||||
{{- $svcName := include "ix.v1.common.names.fullname" $root -}}
|
||||
|
||||
{{- if and (hasKey $svcValues "nameOverride") $svcValues.nameOverride -}}
|
||||
{{- $svcName = (printf "%v-%v" $svcName $svcValues.nameOverride) -}}
|
||||
{{- end -}}
|
||||
{{- $svcName := include "ix.v1.common.names.service" (dict "root" $root "svcValues" $svcValues) -}}
|
||||
|
||||
{{- $svcType := $svcValues.type | default $defaultServiceType -}}
|
||||
{{- if $root.Values.hostNetwork -}}
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
{{/* Template for a ServiceAccount object, can only be called by the spawner */}}
|
||||
{{/* A serviceAccount object and "root" is passed from the spawner */}}
|
||||
{{- define "ix.v1.common.class.serviceAccount" -}}
|
||||
{{- $values := .serviceAccount -}}
|
||||
{{- $saValues := .serviceAccount -}}
|
||||
{{- $root := .root -}}
|
||||
|
||||
{{- $saName := include "ix.v1.common.names.fullname" $root -}}
|
||||
|
||||
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
|
||||
{{- $saName = (printf "%v-%v" $saName $values.nameOverride) -}}
|
||||
{{- end }}
|
||||
|
||||
{{- $saName := include "ix.v1.common.names.serviceAccount" (dict "root" $root "saValues" $saValues) }}
|
||||
---
|
||||
apiVersion: {{ include "ix.v1.common.capabilities.serviceAccount.apiVersion" $root }}
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ $saName }}
|
||||
{{- $labels := (mustMerge ($values.labels | default dict) (include "ix.v1.common.labels" $root | fromYaml)) -}}
|
||||
{{- $labels := (mustMerge ($saValues.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 := (mustMerge ($values.annotations | default dict) (include "ix.v1.common.annotations" $root | fromYaml)) -}}
|
||||
{{- $annotations := (mustMerge ($saValues.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 }}
|
||||
|
||||
@@ -5,33 +5,14 @@
|
||||
{{- $tlsCrtKey := "tls.crt" -}}
|
||||
{{- $tlsPrivateKey := "tls.key" -}}
|
||||
|
||||
|
||||
{{- if ne $name ($name | lower) -}}
|
||||
{{- fail (printf "Certificate has invalid name (%s). Name must be lowercase." $name) -}}
|
||||
{{- end -}}
|
||||
{{- if contains "_" $name -}}
|
||||
{{- fail (printf "Certificate has invalid name (%s). Name cannot contain underscores (_)" $name) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Default to $name if there is not a nameOverride given */}}
|
||||
{{- if not $cert.nameOverride -}}
|
||||
{{- $_ := set $cert "nameOverride" $name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (hasKey $cert "id") -}} {{/* This is something that should not happen when using this library */}}
|
||||
{{- fail (printf "Certificate (%s) has no <id> key" $cert.nameOverride) -}}
|
||||
{{- 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)) -}}
|
||||
{{/* Generate secret name here so we can pass it to persistence if needed */}}
|
||||
{{- $secretName := include "ix.v1.common.names.fullname" $root -}}
|
||||
{{- if $cert.nameOverride -}}
|
||||
{{- $secretName = (printf "%v-%v-%v-%v" $secretName $cert.nameOverride "ixcert" $certID) -}}
|
||||
{{- else -}}
|
||||
{{- $secretName = (printf "%v-%v-%v" $secretName "ixcert" $certID) -}}
|
||||
{{- end -}}
|
||||
{{- $secretName = (printf "%v-%v" $secretName $root.Release.Revision) -}}
|
||||
{{/* Generate secret name here so we can pass it to persistenc */}}
|
||||
{{- $secretName := include "ix.v1.common.names.certificateSecret" (dict "root" $root "certValues" $cert "certName" $name "certID" $certID) -}}
|
||||
|
||||
{{- include "ix.v1.common.certificate.persistence" (dict "root" $root "secretName" $secretName "cert" $cert "certID" $certID "tlsKey" $tlsCrtKey "type" "cert") -}}
|
||||
{{- include "ix.v1.common.certificate.persistence" (dict "root" $root "secretName" $secretName "cert" $cert "certID" $certID "tlsKey" $tlsPrivateKey "type" "key") -}}
|
||||
|
||||
@@ -88,6 +88,24 @@ nameOverride applies only to the current chart
|
||||
{{- $serviceAccountName -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Returns the service name */}}
|
||||
{{- define "ix.v1.common.names.serviceAccount" -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $saValues := .saValues -}}
|
||||
|
||||
{{- if or (not $root) (not $saValues) -}}
|
||||
{{- fail "Named function <names.serviceAccount> did not receive required values" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $saName := include "ix.v1.common.names.fullname" $root -}}
|
||||
|
||||
{{- if and (hasKey $saValues "nameOverride") $saValues.nameOverride -}}
|
||||
{{- $saName = (printf "%v-%v" $saName $saValues.nameOverride) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $saName -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Returns the pvcName. */}}
|
||||
{{- define "ix.v1.common.names.pvc" -}}
|
||||
{{- $root := .root -}}
|
||||
@@ -170,3 +188,55 @@ nameOverride applies only to the current chart
|
||||
|
||||
{{- $generatedName -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Returns the name for certificate secret */}}
|
||||
{{- define "ix.v1.common.names.certificateSecret" -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $certName := .certName -}}
|
||||
{{- $certValues := .certValues -}}
|
||||
{{- $certID := .certID -}}
|
||||
|
||||
{{- if or (not $root) (not $certName) (not $certValues) (not $certID) -}}
|
||||
{{- fail "Named function <names.certificateSecret> did not receive required values" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if ne $certName ($certName | lower) -}}
|
||||
{{- fail (printf "Certificate has invalid name (%s). Name must be lowercase." $certName) -}}
|
||||
{{- end -}}
|
||||
{{- if contains "_" $certName -}}
|
||||
{{- fail (printf "Certificate has invalid name (%s). Name cannot contain underscores (_)" $certName) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Default to $name if there is not a nameOverride given */}}
|
||||
{{- if not $certValues.nameOverride -}}
|
||||
{{- $_ := set $certValues "nameOverride" $certName -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $secretName := include "ix.v1.common.names.fullname" $root -}}
|
||||
{{- if $certValues.nameOverride -}}
|
||||
{{- $secretName = (printf "%v-%v-%v-%v" $secretName $certValues.nameOverride "ixcert" $certID) -}}
|
||||
{{- else -}}
|
||||
{{- $secretName = (printf "%v-%v-%v" $secretName "ixcert" $certID) -}}
|
||||
{{- end -}}
|
||||
{{- $secretName = (printf "%v-%v" $secretName $root.Release.Revision) -}}
|
||||
|
||||
{{- $secretName -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Returns the serviceName. */}}
|
||||
{{- define "ix.v1.common.names.service" -}}
|
||||
{{- $root := .root -}}
|
||||
{{- $svcValues := .svcValues -}}
|
||||
|
||||
{{- if or (not $root) (not $svcValues) -}}
|
||||
{{- fail "Named function <names.service> did not receive required values" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $svcName := include "ix.v1.common.names.fullname" $root -}}
|
||||
|
||||
{{- if and (hasKey $svcValues "nameOverride") $svcValues.nameOverride -}}
|
||||
{{- $svcName = (printf "%v-%v" $svcName $svcValues.nameOverride) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $svcName -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user