mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 08:57:04 +02:00
feat(common): Release version 2.0.0-beta.1 (#173)
This commit is contained in:
parent
19767d668c
commit
7b6ee00be6
189 changed files with 3110 additions and 3023 deletions
|
@ -0,0 +1,28 @@
|
|||
{{- /*
|
||||
Returns the value for containers
|
||||
*/ -}}
|
||||
{{- define "bjw-s.common.lib.pod.field.containers" -}}
|
||||
{{- $rootContext := .ctx.rootContext -}}
|
||||
{{- $controllerObject := .ctx.controllerObject -}}
|
||||
|
||||
{{- /* Default to empty list */ -}}
|
||||
{{- $containers := list -}}
|
||||
|
||||
{{- /* Fetch configured containers for this controller */ -}}
|
||||
{{- $enabledContainers := include "bjw-s.common.lib.controller.enabledContainers" (dict "rootContext" $rootContext "controllerObject" $controllerObject) | fromYaml }}
|
||||
{{- range $key, $containerValues := $enabledContainers -}}
|
||||
{{- /* Create object from the container values */ -}}
|
||||
{{- $containerObject := (include "bjw-s.common.lib.container.valuesToObject" (dict "rootContext" $ "id" $key "values" $containerValues)) | fromYaml -}}
|
||||
|
||||
{{- /* Perform validations on the Container before rendering */ -}}
|
||||
{{- include "bjw-s.common.lib.container.validate" (dict "rootContext" $ "object" $containerObject) -}}
|
||||
|
||||
{{- /* Generate the Container spec */ -}}
|
||||
{{- $renderedContainer := include "bjw-s.common.lib.container.spec" (dict "rootContext" $rootContext "controllerObject" $controllerObject "containerObject" $containerObject) | fromYaml -}}
|
||||
{{- $containers = append $containers $renderedContainer -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (empty $containers) -}}
|
||||
{{- $containers | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,25 @@
|
|||
{{- /*
|
||||
Returns the value for dnsPolicy
|
||||
*/ -}}
|
||||
{{- define "bjw-s.common.lib.pod.field.dnsPolicy" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $controllerObject := $ctx.controllerObject -}}
|
||||
|
||||
{{- /* Default to "ClusterFirst" */ -}}
|
||||
{{- $dnsPolicy := "ClusterFirst" -}}
|
||||
|
||||
{{- /* Get hostNetwork value "" */ -}}
|
||||
{{- $hostNetwork:= get $controllerObject.pod "hostNetwork" -}}
|
||||
{{- if $hostNetwork -}}
|
||||
{{- $dnsPolicy = "ClusterFirstWithHostNet" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* See if an override is desired */ -}}
|
||||
{{- $override := get $controllerObject.pod "dnsPolicy" -}}
|
||||
|
||||
{{- if not (empty $override) -}}
|
||||
{{- $dnsPolicy = $override -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $dnsPolicy -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,27 @@
|
|||
{{- /*
|
||||
Returns the value for initContainers
|
||||
*/ -}}
|
||||
{{- define "bjw-s.common.lib.pod.field.initContainers" -}}
|
||||
{{- $rootContext := .ctx.rootContext -}}
|
||||
{{- $controllerObject := .ctx.controllerObject -}}
|
||||
|
||||
{{- /* Default to empty list */ -}}
|
||||
{{- $containers := list -}}
|
||||
|
||||
{{- /* Fetch configured containers for this controller */ -}}
|
||||
{{- range $key, $containerValues := $controllerObject.initContainers -}}
|
||||
{{- /* Create object from the container values */ -}}
|
||||
{{- $containerObject := (include "bjw-s.common.lib.container.valuesToObject" (dict "rootContext" $ "id" $key "values" $containerValues)) | fromYaml -}}
|
||||
|
||||
{{- /* Perform validations on the Container before rendering */ -}}
|
||||
{{- include "bjw-s.common.lib.container.validate" (dict "rootContext" $ "object" $containerObject) -}}
|
||||
|
||||
{{- /* Generate the Container spec */ -}}
|
||||
{{- $renderedContainer := include "bjw-s.common.lib.container.spec" (dict "rootContext" $rootContext "containerObject" $containerObject) | fromYaml -}}
|
||||
{{- $containers = append $containers $renderedContainer -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (empty $containers) -}}
|
||||
{{- $containers | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,18 @@
|
|||
{{- /*
|
||||
Returns the value for serviceAccountName
|
||||
*/ -}}
|
||||
{{- define "bjw-s.common.lib.pod.field.serviceAccountName" -}}
|
||||
{{- $rootContext := .ctx.rootContext -}}
|
||||
|
||||
{{- /* Default to "default" */ -}}
|
||||
{{- $name := "default" -}}
|
||||
|
||||
{{- /* See if an override is needed */ -}}
|
||||
{{- if $rootContext.Values.serviceAccount.create -}}
|
||||
{{- $serviceAccountValues := (mustDeepCopy $rootContext.Values.serviceAccount) -}}
|
||||
{{- $serviceAccountObject := (include "bjw-s.common.lib.serviceAccount.valuesToObject" (dict "rootContext" $rootContext "id" "default" "values" $serviceAccountValues)) | fromYaml -}}
|
||||
{{- $name = $serviceAccountObject.name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $name -}}
|
||||
{{- end -}}
|
118
charts/library/common/templates/lib/pod/fields/_volumes.tpl
Normal file
118
charts/library/common/templates/lib/pod/fields/_volumes.tpl
Normal file
|
@ -0,0 +1,118 @@
|
|||
{{- /*
|
||||
Returns the value for volumes
|
||||
*/ -}}
|
||||
{{- define "bjw-s.common.lib.pod.field.volumes" -}}
|
||||
{{- $rootContext := .ctx.rootContext -}}
|
||||
{{- $controllerObject := .ctx.controllerObject -}}
|
||||
|
||||
{{- /* Default to empty list */ -}}
|
||||
{{- $persistenceItemsToProcess := dict -}}
|
||||
{{- $volumes := list -}}
|
||||
|
||||
{{- /* Loop over persistence values */ -}}
|
||||
{{- range $identifier, $persistenceValues := $rootContext.Values.persistence -}}
|
||||
{{- /* Enable persistence item by default, but allow override */ -}}
|
||||
{{- $persistenceEnabled := true -}}
|
||||
{{- if hasKey $persistenceValues "enabled" -}}
|
||||
{{- $persistenceEnabled = $persistenceValues.enabled -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $persistenceEnabled -}}
|
||||
{{- $advancedMounts := dig "advancedMounts" $controllerObject.identifier list $persistenceValues -}}
|
||||
{{- if $advancedMounts -}}
|
||||
{{- $_ := set $persistenceItemsToProcess $identifier $persistenceValues -}}
|
||||
{{- else -}}
|
||||
{{- $_ := set $persistenceItemsToProcess $identifier $persistenceValues -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Loop over persistence items */ -}}
|
||||
{{- range $identifier, $persistenceValues := $persistenceItemsToProcess -}}
|
||||
{{- $volume := dict "name" $identifier -}}
|
||||
|
||||
{{- /* PVC persistence type */ -}}
|
||||
{{- if eq (default "persistentVolumeClaim" $persistenceValues.type) "persistentVolumeClaim" -}}
|
||||
{{- $pvcName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
|
||||
{{- if $persistenceValues.existingClaim -}}
|
||||
{{- /* Always prefer an existingClaim if that is set */ -}}
|
||||
{{- $pvcName = $persistenceValues.existingClaim -}}
|
||||
{{- else -}}
|
||||
{{- /* Otherwise refer to the PVC name */ -}}
|
||||
{{- if $persistenceValues.nameOverride -}}
|
||||
{{- if not (eq $persistenceValues.nameOverride "-") -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $rootContext) $persistenceValues.nameOverride) -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $rootContext) $identifier) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $volume "persistentVolumeClaim" (dict "claimName" $pvcName) -}}
|
||||
|
||||
{{- /* configMap persistence type */ -}}
|
||||
{{- else if eq $persistenceValues.type "configMap" -}}
|
||||
{{- $objectName := (required (printf "name not set for persistence item %s" $identifier) $persistenceValues.name) -}}
|
||||
{{- $objectName = tpl $objectName $rootContext -}}
|
||||
{{- $_ := set $volume "configMap" dict -}}
|
||||
{{- $_ := set $volume.configMap "name" $objectName -}}
|
||||
{{- with $persistenceValues.defaultMode -}}
|
||||
{{- $_ := set $volume.configMap "defaultMode" . -}}
|
||||
{{- end -}}
|
||||
{{- with $persistenceValues.items -}}
|
||||
{{- $_ := set $volume.configMap "items" . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Secret persistence type */ -}}
|
||||
{{- else if eq $persistenceValues.type "secret" -}}
|
||||
{{- $objectName := (required (printf "name not set for persistence item %s" $identifier) $persistenceValues.name) -}}
|
||||
{{- $objectName = tpl $objectName $rootContext -}}
|
||||
{{- $_ := set $volume "secret" dict -}}
|
||||
{{- $_ := set $volume.secret "secretName" $objectName -}}
|
||||
{{- with $persistenceValues.defaultMode -}}
|
||||
{{- $_ := set $volume.secret "defaultMode" . -}}
|
||||
{{- end -}}
|
||||
{{- with $persistenceValues.items -}}
|
||||
{{- $_ := set $volume.secret "items" . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* emptyDir persistence type */ -}}
|
||||
{{- else if eq $persistenceValues.type "emptyDir" -}}
|
||||
{{- $_ := set $volume "emptyDir" dict -}}
|
||||
{{- with $persistenceValues.medium -}}
|
||||
{{- $_ := set $volume.emptyDir "medium" . -}}
|
||||
{{- end -}}
|
||||
{{- with $persistenceValues.sizeLimit -}}
|
||||
{{- $_ := set $volume.emptyDir "sizeLimit" . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* hostPath persistence type */ -}}
|
||||
{{- else if eq $persistenceValues.type "hostPath" -}}
|
||||
{{- $_ := set $volume "hostPath" dict -}}
|
||||
{{- $_ := set $volume.hostPath "path" (required "hostPath not set" $persistenceValues.hostPath) -}}
|
||||
{{- with $persistenceValues.hostPathType }}
|
||||
{{- $_ := set $volume.hostPath "type" . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* hostPath persistence type */ -}}
|
||||
{{- else if eq $persistenceValues.type "nfs" -}}
|
||||
{{- $_ := set $volume "nfs" dict -}}
|
||||
{{- $_ := set $volume.nfs "server" (required "server not set" $persistenceValues.server) -}}
|
||||
{{- $_ := set $volume.nfs "path" (required "path not set" $persistenceValues.path) -}}
|
||||
|
||||
{{- /* custom persistence type */ -}}
|
||||
{{- else if eq $persistenceValues.type "custom" -}}
|
||||
{{- $volume = $persistenceValues.volumeSpec -}}
|
||||
{{- $_ := set $volume "name" $identifier -}}
|
||||
|
||||
{{- /* Fail otherwise */ -}}
|
||||
{{- else -}}
|
||||
{{- fail (printf "Not a valid persistence.type (%s)" $persistenceValues.type) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $volumes = append $volumes $volume -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (empty $volumes) -}}
|
||||
{{- $volumes | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
Loading…
Add table
Add a link
Reference in a new issue