mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 00:47: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,26 @@
|
|||
{{/*
|
||||
Args used by the container.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.field.args" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
|
||||
{{- /* Default to empty list */ -}}
|
||||
{{- $args := list -}}
|
||||
|
||||
{{- /* See if an override is desired */ -}}
|
||||
{{- if not (empty (get $containerObject "args")) -}}
|
||||
{{- $option := get $containerObject "args" -}}
|
||||
{{- if not (empty $option) -}}
|
||||
{{- if kindIs "string" $option -}}
|
||||
{{- $args = append $args $option -}}
|
||||
{{- else -}}
|
||||
{{- $args = $option -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (empty $args) -}}
|
||||
{{- $args | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,26 @@
|
|||
{{/*
|
||||
Command used by the container.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.field.command" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
|
||||
{{- /* Default to empty list */ -}}
|
||||
{{- $command := list -}}
|
||||
|
||||
{{- /* See if an override is desired */ -}}
|
||||
{{- if not (empty (get $containerObject "command")) -}}
|
||||
{{- $option := get $containerObject "command" -}}
|
||||
{{- if not (empty $option) -}}
|
||||
{{- if kindIs "string" $option -}}
|
||||
{{- $command = append $command $option -}}
|
||||
{{- else -}}
|
||||
{{- $command = $option -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (empty $command) -}}
|
||||
{{- $command | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,45 @@
|
|||
{{/*
|
||||
Env field used by the container.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.field.env" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $rootContext := $ctx.rootContext -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
|
||||
{{- /* Default to empty list */ -}}
|
||||
{{- $env := list -}}
|
||||
|
||||
{{- /* See if an override is desired */ -}}
|
||||
{{- if not (empty (get $containerObject "env")) -}}
|
||||
{{- with $containerObject.env -}}
|
||||
{{- range $name, $value := . -}}
|
||||
{{- if kindIs "int" $name -}}
|
||||
{{- $name = required "environment variables as a list of maps require a name field" $value.name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if kindIs "map" $value -}}
|
||||
{{- if hasKey $value "value" -}}
|
||||
{{- $envValue := $value.value | toString -}}
|
||||
{{- $env = append $env (dict "name" $name "value" (tpl $envValue $rootContext)) -}}
|
||||
{{- else if hasKey $value "valueFrom" -}}
|
||||
{{- $env = append $env (dict "name" $name "valueFrom" $value.valueFrom) -}}
|
||||
{{- else -}}
|
||||
{{- $env = append $env (dict "name" $name "valueFrom" $value) -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- if kindIs "string" $value -}}
|
||||
{{- $env = append $env (dict "name" $name "value" (tpl $value $rootContext)) -}}
|
||||
{{- else if or (kindIs "float64" $value) (kindIs "bool" $value) -}}
|
||||
{{- $env = append $env (dict "name" $name "value" ($value | toString)) -}}
|
||||
{{- else -}}
|
||||
{{- $env = append $env (dict "name" $name "value" $value) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (empty $env) -}}
|
||||
{{- $env | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,19 @@
|
|||
{{/*
|
||||
Image used by the container.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.field.image" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $rootContext := $ctx.rootContext -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
|
||||
{{- $imageRepo := $containerObject.image.repository -}}
|
||||
{{- $imageTag := default $rootContext.Chart.AppVersion $containerObject.image.tag -}}
|
||||
|
||||
{{- if kindIs "float64" $imageTag -}}
|
||||
{{- $imageTag = $imageTag | toString -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and $imageRepo $imageTag -}}
|
||||
{{- printf "%s:%s" $imageRepo $imageTag -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,24 @@
|
|||
{{/*
|
||||
Name used by the container.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.field.name" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $rootContext := $ctx.rootContext -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
|
||||
{{- /* Default to container identifier */ -}}
|
||||
{{- $name := $containerObject.identifier -}}
|
||||
|
||||
{{- /* See if an override is desired */ -}}
|
||||
{{- if hasKey $containerObject "nameOverride" -}}
|
||||
{{- $option := get $containerObject "nameOverride" -}}
|
||||
{{- if not (empty $option) -}}
|
||||
{{- $name = $option -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Parse any templates */ -}}
|
||||
{{- $name = tpl $name $rootContext -}}
|
||||
|
||||
{{- $name | toYaml -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,79 @@
|
|||
{{/*
|
||||
Probes used by the container.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.field.probes" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $rootContext := $ctx.rootContext -}}
|
||||
{{- $controllerObject := $ctx.controllerObject -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
|
||||
{{- /* Default to empty dict */ -}}
|
||||
{{- $enabledProbes := dict -}}
|
||||
|
||||
{{- range $probeName, $probeValues := $containerObject.probes -}}
|
||||
{{- /* Disable probe by default, but allow override */ -}}
|
||||
{{- $probeEnabled := false -}}
|
||||
{{- if hasKey $probeValues "enabled" -}}
|
||||
{{- $probeEnabled = $probeValues.enabled -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $probeEnabled -}}
|
||||
{{- $probeDefinition := dict -}}
|
||||
|
||||
{{- if $probeValues.custom -}}
|
||||
{{- $parsedProbeSpec := tpl ($probeValues.spec | toYaml) $rootContext -}}
|
||||
{{- $probeDefinition = $parsedProbeSpec | fromYaml -}}
|
||||
{{- else -}}
|
||||
{{- $primaryService := include "bjw-s.common.lib.service.primaryForController" (dict "rootContext" $rootContext "controllerIdentifier" $controllerObject.identifier) | fromYaml -}}
|
||||
{{- $primaryServiceDefaultPort := dict -}}
|
||||
{{- if $primaryService -}}
|
||||
{{- $primaryServiceDefaultPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $primaryService) | fromYaml -}}
|
||||
{{- end -}}
|
||||
{{- if $primaryServiceDefaultPort -}}
|
||||
{{- $probeType := "" -}}
|
||||
{{- if eq $probeValues.type "AUTO" -}}
|
||||
{{- $probeType = $primaryServiceDefaultPort.protocol -}}
|
||||
{{- else -}}
|
||||
{{- $probeType = $probeValues.type | default "TCP" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $_ := set $probeDefinition "initialDelaySeconds" $probeValues.spec.initialDelaySeconds -}}
|
||||
{{- $_ := set $probeDefinition "failureThreshold" $probeValues.spec.failureThreshold -}}
|
||||
{{- $_ := set $probeDefinition "timeoutSeconds" $probeValues.spec.timeoutSeconds -}}
|
||||
{{- $_ := set $probeDefinition "periodSeconds" $probeValues.spec.periodSeconds -}}
|
||||
|
||||
{{- $probeHeader := "" -}}
|
||||
{{- if or ( eq $probeType "HTTPS" ) ( eq $probeType "HTTP" ) -}}
|
||||
{{- $probeHeader = "httpGet" -}}
|
||||
|
||||
{{- $_ := set $probeDefinition $probeHeader (
|
||||
dict
|
||||
"path" $probeValues.path
|
||||
"scheme" $probeType
|
||||
)
|
||||
-}}
|
||||
{{- else }}
|
||||
{{- $probeHeader = "tcpSocket" -}}
|
||||
{{- $_ := set $probeDefinition $probeHeader dict -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $probeValues.port -}}
|
||||
{{- $_ := set (index $probeDefinition $probeHeader) "port" (tpl ( $probeValues.port | toString ) $rootContext) -}}
|
||||
{{- else if $primaryServiceDefaultPort.targetPort -}}
|
||||
{{- $_ := set (index $probeDefinition $probeHeader) "port" $primaryServiceDefaultPort.targetPort -}}
|
||||
{{- else -}}
|
||||
{{- $_ := set (index $probeDefinition $probeHeader) "port" ($primaryServiceDefaultPort.port | toString | atoi ) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $probeDefinition -}}
|
||||
{{- $_ := set $enabledProbes (printf "%sProbe" $probeName) $probeDefinition -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $enabledProbes -}}
|
||||
{{- . | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,77 @@
|
|||
{{/*
|
||||
volumeMounts used by the container.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.field.volumeMounts" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $rootContext := $ctx.rootContext -}}
|
||||
{{- $controllerObject := $ctx.controllerObject -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
|
||||
{{- /* Default to empty dict */ -}}
|
||||
{{- $persistenceItemsToProcess := dict -}}
|
||||
{{- $enabledVolumeMounts := list -}}
|
||||
|
||||
{{- 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 -}}
|
||||
{{- /* Set some default values */ -}}
|
||||
|
||||
{{- /* Set the default mountPath to /<name_of_the_peristence_item> */ -}}
|
||||
{{- $mountPath := (printf "/%v" $identifier) -}}
|
||||
{{- if eq "hostPath" (default "pvc" $persistenceValues.type) -}}
|
||||
{{- $mountPath = $persistenceValues.hostPath -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Process configured mounts */ -}}
|
||||
{{- if or .globalMounts .advancedMounts -}}
|
||||
{{- $mounts := list -}}
|
||||
{{- if hasKey . "globalMounts" -}}
|
||||
{{- $mounts = .globalMounts -}}
|
||||
{{- else if hasKey . "advancedMounts" -}}
|
||||
{{- $mounts = dig $controllerObject.identifier $containerObject.identifier list .advancedMounts -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- range $mounts -}}
|
||||
{{- $volumeMount := dict -}}
|
||||
{{- $_ := set $volumeMount "name" $identifier -}}
|
||||
|
||||
{{- /* Use the specified mountPath if provided */ -}}
|
||||
{{- with .path -}}
|
||||
{{- $mountPath = . -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $volumeMount "mountPath" $mountPath -}}
|
||||
|
||||
{{- /* Use the specified subPath if provided */ -}}
|
||||
{{- with .subPath -}}
|
||||
{{- $subPath := . -}}
|
||||
{{- $_ := set $volumeMount "subPath" $subPath -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Use the specified readOnly setting if provided */ -}}
|
||||
{{- with .readOnly -}}
|
||||
{{- $readOnly := . -}}
|
||||
{{- $_ := set $volumeMount "readOnly" $readOnly -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $enabledVolumeMounts = append $enabledVolumeMounts $volumeMount -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Mount to default path if no mounts are configured */ -}}
|
||||
{{- else -}}
|
||||
{{- $volumeMount := dict -}}
|
||||
{{- $_ := set $volumeMount "name" $identifier -}}
|
||||
{{- $_ := set $volumeMount "mountPath" $mountPath -}}
|
||||
{{- $enabledVolumeMounts = append $enabledVolumeMounts $volumeMount -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $enabledVolumeMounts -}}
|
||||
{{- . | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
Loading…
Add table
Add a link
Reference in a new issue