feat(common)!: Release v3.0.0-beta1 (#278)

This commit is contained in:
Bernd Schorgers 2024-03-07 19:53:41 +01:00 committed by GitHub
parent deafcf75a1
commit b78483b0b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
88 changed files with 3697 additions and 1209 deletions

View file

@ -47,6 +47,9 @@ ports: {{ toYaml . | trim | nindent 2 }}
{{- end -}}
{{- with $containerObject.resources }}
resources: {{ toYaml . | trim | nindent 2 }}
{{- end -}}
{{- with $containerObject.restartPolicy }}
restartPolicy: {{ . | trim }}
{{- end -}}
{{- with (include "bjw-s.common.lib.container.field.volumeMounts" (dict "ctx" $ctx) | trim) }}
volumeMounts: {{ . | trim | nindent 2 }}

View file

@ -24,6 +24,8 @@ Probes used by the container.
{{- $parsedProbeSpec := tpl ($probeValues.spec | toYaml) $rootContext -}}
{{- $probeDefinition = $parsedProbeSpec | fromYaml -}}
{{- else -}}
{{- $probeSpec := dig "spec" dict $probeValues -}}
{{- $primaryService := include "bjw-s.common.lib.service.primaryForController" (dict "rootContext" $rootContext "controllerIdentifier" $controllerObject.identifier) | fromYaml -}}
{{- $primaryServiceDefaultPort := dict -}}
{{- if $primaryService -}}
@ -37,10 +39,10 @@ Probes used by the container.
{{- $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 -}}
{{- $_ := set $probeDefinition "initialDelaySeconds" (default 0 $probeSpec.initialDelaySeconds) -}}
{{- $_ := set $probeDefinition "failureThreshold" (default 3 $probeSpec.failureThreshold) -}}
{{- $_ := set $probeDefinition "timeoutSeconds" (default 1 $probeSpec.timeoutSeconds) -}}
{{- $_ := set $probeDefinition "periodSeconds" (default 10 $probeSpec.periodSeconds) -}}
{{- $probeHeader := "" -}}
{{- if or ( eq $probeType "HTTPS" ) ( eq $probeType "HTTP" ) -}}

View file

@ -24,18 +24,6 @@ Convert controller values to an object
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Set the default Pod options for the controller */ -}}
{{- range $index, $key := keys $rootContext.Values.defaultPodOptions -}}
{{- if not (hasKey $objectValues "pod") -}}
{{- $_ := set $objectValues "pod" dict -}}
{{- end -}}
{{- $defaultValue := get $rootContext.Values.defaultPodOptions $key -}}
{{- if not (hasKey $objectValues.pod $key) -}}
{{- $_ := set $objectValues.pod $key $defaultValue -}}
{{- end -}}
{{- end -}}
{{- /* Return the controller object */ -}}
{{- $objectValues | toYaml -}}
{{- end -}}

View file

@ -1,21 +0,0 @@
{{/* Return the name of the primary Ingress object */}}
{{- define "bjw-s.common.lib.ingress.primary" -}}
{{- $enabledIngresses := dict -}}
{{- range $name, $ingress := .Values.ingress -}}
{{- if $ingress.enabled -}}
{{- $_ := set $enabledIngresses $name . -}}
{{- end -}}
{{- end -}}
{{- $result := "" -}}
{{- range $name, $ingress := $enabledIngresses -}}
{{- if and (hasKey $ingress "primary") $ingress.primary -}}
{{- $result = $name -}}
{{- end -}}
{{- end -}}
{{- if not $result -}}
{{- $result = keys $enabledIngresses | first -}}
{{- end -}}
{{- $result -}}
{{- end -}}

View file

@ -6,6 +6,10 @@ Convert job values to an object
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- if not (hasKey $objectValues "pod") -}}
{{- $_ := set $objectValues "pod" dict -}}
{{- end -}}
{{- $restartPolicy := default "Never" $objectValues.pod.restartPolicy -}}
{{- $_ := set $objectValues.pod "restartPolicy" $restartPolicy -}}

View file

@ -5,11 +5,12 @@ Returns the value for the specified field
{{- $rootContext := .ctx.rootContext -}}
{{- $controllerObject := .ctx.controllerObject -}}
{{- $option := .option -}}
{{- $default := default "" .default -}}
{{- $value := "" -}}
{{- $value := $default -}}
{{- /* Set to the default if it is set */ -}}
{{- $defaultOption := get $rootContext.Values.defaultPodOptions $option -}}
{{- $defaultOption := dig $option nil (default dict $rootContext.Values.defaultPodOptions) -}}
{{- if kindIs "bool" $defaultOption -}}
{{- $value = $defaultOption -}}
{{- else if not (empty $defaultOption) -}}
@ -17,13 +18,11 @@ Returns the value for the specified field
{{- end -}}
{{- /* See if a pod-specific override is needed */ -}}
{{- if hasKey $controllerObject "pod" -}}
{{- $podOption := get $controllerObject.pod $option -}}
{{- if kindIs "bool" $podOption -}}
{{- $value = $podOption -}}
{{- else if not (empty $podOption) -}}
{{- $value = $podOption -}}
{{- end -}}
{{- $podOption := dig $option nil (default dict $controllerObject.pod) -}}
{{- if kindIs "bool" $podOption -}}
{{- $value = $podOption -}}
{{- else if not (empty $podOption) -}}
{{- $value = $podOption -}}
{{- end -}}
{{- if kindIs "bool" $value -}}

View file

@ -6,54 +6,54 @@ The pod definition included in the controller.
{{- $controllerObject := .controllerObject -}}
{{- $ctx := dict "rootContext" $rootContext "controllerObject" $controllerObject -}}
enableServiceLinks: {{ $controllerObject.pod.enableServiceLinks }}
enableServiceLinks: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "enableServiceLinks" "default" false) }}
serviceAccountName: {{ include "bjw-s.common.lib.pod.field.serviceAccountName" (dict "ctx" $ctx) | trim }}
automountServiceAccountToken: {{ $controllerObject.pod.automountServiceAccountToken }}
{{- with ($controllerObject.pod.priorityClassName) }}
automountServiceAccountToken: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "automountServiceAccountToken" "default" true) }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "priorityClassName")) }}
priorityClassName: {{ . | trim }}
{{- end -}}
{{- with ($controllerObject.pod.runtimeClassName) }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "runtimeClassName")) }}
runtimeClassName: {{ . | trim }}
{{- end -}}
{{- with ($controllerObject.pod.schedulerName) }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "schedulerName")) }}
schedulerName: {{ . | trim }}
{{- end -}}
{{- with ($controllerObject.pod.securityContext) }}
securityContext: {{ . | toYaml | nindent 2 }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "securityContext")) }}
securityContext: {{ . | nindent 2 }}
{{- end -}}
{{- with ($controllerObject.pod.hostname) }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostname")) }}
hostname: {{ . | trim }}
{{- end }}
hostIPC: {{ $controllerObject.pod.hostIPC }}
hostNetwork: {{ $controllerObject.pod.hostNetwork }}
hostPID: {{ $controllerObject.pod.hostPID }}
hostIPC: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostIPC" "default" false) }}
hostNetwork: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostNetwork" "default" false) }}
hostPID: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostPID" "default" false) }}
dnsPolicy: {{ include "bjw-s.common.lib.pod.field.dnsPolicy" (dict "ctx" $ctx) | trim }}
{{- with $controllerObject.pod.dnsConfig }}
dnsConfig: {{ . | toYaml | nindent 2 }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "dnsConfig")) }}
dnsConfig: {{ . | nindent 2 }}
{{- end -}}
{{- with $controllerObject.pod.hostAliases }}
hostAliases: {{ . | toYaml | nindent 2 }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostAliases")) }}
hostAliases: {{ . | nindent 2 }}
{{- end -}}
{{- with $controllerObject.pod.imagePullSecrets }}
imagePullSecrets: {{ . | toYaml | nindent 2 }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "imagePullSecrets")) }}
imagePullSecrets: {{ . | nindent 2 }}
{{- end -}}
{{- with $controllerObject.pod.terminationGracePeriodSeconds }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "terminationGracePeriodSeconds")) }}
terminationGracePeriodSeconds: {{ . | trim }}
{{- end -}}
{{- with $controllerObject.pod.restartPolicy }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "restartPolicy")) }}
restartPolicy: {{ . | trim }}
{{- end -}}
{{- with $controllerObject.pod.nodeSelector }}
nodeSelector: {{ . | toYaml | nindent 2 }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "nodeSelector")) }}
nodeSelector: {{ . | nindent 2 }}
{{- end -}}
{{- with $controllerObject.pod.affinity }}
affinity: {{ . | toYaml | nindent 2 }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "affinity")) }}
affinity: {{ . | nindent 2 }}
{{- end -}}
{{- with $controllerObject.pod.topologySpreadConstraints }}
topologySpreadConstraints: {{ . | toYaml | nindent 2 }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "topologySpreadConstraints")) }}
topologySpreadConstraints: {{ . | nindent 2 }}
{{- end -}}
{{- with $controllerObject.pod.tolerations }}
tolerations: {{ . | toYaml | nindent 2 }}
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "tolerations")) }}
tolerations: {{ . | nindent 2 }}
{{- end }}
{{- with (include "bjw-s.common.lib.pod.field.initContainers" (dict "ctx" $ctx) | trim) }}
initContainers: {{ . | nindent 2 }}

View file

@ -13,10 +13,6 @@ Returns the value for containers
{{- $enabledContainers := include "bjw-s.common.lib.controller.enabledContainers" (dict "rootContext" $rootContext "controllerObject" $controllerObject) | fromYaml }}
{{- $renderedContainers := dict -}}
{{- /* TODO: Remove this logic after "order" removal in v3 */ -}}
{{- $containersWithDependsOn := include "bjw-s.common.lib.getMapItemsWithKey" (dict "map" $enabledContainers "key" "dependsOn") | fromYaml | keys -}}
{{- $useDependsOn := gt (len $containersWithDependsOn) 0 -}}
{{- range $key, $containerValues := $enabledContainers -}}
{{- /* Create object from the container values */ -}}
{{- $containerObject := (include "bjw-s.common.lib.container.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $containerValues)) | fromYaml -}}
@ -29,40 +25,23 @@ Returns the value for containers
{{- $_ := set $renderedContainers $key $renderedContainer -}}
{{- /* Determine the Container order */ -}}
{{- if $useDependsOn -}}
{{- if empty (dig "dependsOn" nil $containerValues) -}}
{{- $_ := set $graph $key ( list ) -}}
{{- else if kindIs "string" $containerValues.dependsOn -}}
{{- $_ := set $graph $key ( list $containerValues.dependsOn ) -}}
{{- else if kindIs "slice" $containerValues.dependsOn -}}
{{- $_ := set $graph $key $containerValues.dependsOn -}}
{{- end -}}
{{- else -}}
{{- /* TODO: Remove this logic after "order" removal in v3 */ -}}
{{- $containerOrder := (dig "order" 99 $containerValues) -}}
{{- $_ := set $graph $key $containerOrder -}}
{{- if empty (dig "dependsOn" nil $containerValues) -}}
{{- $_ := set $graph $key ( list ) -}}
{{- else if kindIs "string" $containerValues.dependsOn -}}
{{- $_ := set $graph $key ( list $containerValues.dependsOn ) -}}
{{- else if kindIs "slice" $containerValues.dependsOn -}}
{{- $_ := set $graph $key $containerValues.dependsOn -}}
{{- end -}}
{{- end -}}
{{- /* Process graph */ -}}
{{- if $useDependsOn -}}
{{- $args := dict "graph" $graph "out" list -}}
{{- include "bjw-s.common.lib.kahn" $args -}}
{{- $args := dict "graph" $graph "out" list -}}
{{- include "bjw-s.common.lib.kahn" $args -}}
{{- range $name := $args.out -}}
{{- $containerItem := get $renderedContainers $name -}}
{{- $containers = append $containers $containerItem -}}
{{- end -}}
{{- else -}}
{{- /* TODO: Remove this logic after "order" removal in v3 */ -}}
{{- $orderedContainers := dict -}}
{{- range $key, $order := $graph -}}
{{- $containerItem := get $renderedContainers $key -}}
{{- $_ := set $orderedContainers (printf "%v-%s" $order $key) $containerItem -}}
{{- end -}}
{{- range $key, $containerValues := $orderedContainers -}}
{{- $containers = append $containers $containerValues -}}
{{- end -}}
{{- range $name := $args.out -}}
{{- $containerItem := get $renderedContainers $name -}}
{{- $containers = append $containers $containerItem -}}
{{- end -}}
{{- if not (empty $containers) -}}

View file

@ -9,13 +9,13 @@ Returns the value for dnsPolicy
{{- $dnsPolicy := "ClusterFirst" -}}
{{- /* Get hostNetwork value "" */ -}}
{{- $hostNetwork:= get $controllerObject.pod "hostNetwork" -}}
{{- if $hostNetwork -}}
{{- $hostNetwork:= include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostNetwork") -}}
{{- if (eq $hostNetwork "true") -}}
{{- $dnsPolicy = "ClusterFirstWithHostNet" -}}
{{- end -}}
{{- /* See if an override is desired */ -}}
{{- $override := get $controllerObject.pod "dnsPolicy" -}}
{{- $override := include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "dnsPolicy") -}}
{{- if not (empty $override) -}}
{{- $dnsPolicy = $override -}}

View file

@ -12,10 +12,6 @@ Returns the value for initContainers
{{- /* Fetch configured containers for this controller */ -}}
{{- $renderedContainers := dict -}}
{{- /* TODO: Remove this logic after "order" removal in v3 */ -}}
{{- $containersWithDependsOn := include "bjw-s.common.lib.getMapItemsWithKey" (dict "map" $controllerObject.initContainers "key" "dependsOn") | fromYaml | keys -}}
{{- $useDependsOn := gt (len $containersWithDependsOn) 0 -}}
{{- range $key, $containerValues := $controllerObject.initContainers -}}
{{- /* Enable container by default, but allow override */ -}}
{{- $containerEnabled := true -}}
@ -35,41 +31,23 @@ Returns the value for initContainers
{{- $_ := set $renderedContainers $key $renderedContainer -}}
{{- /* Determine the Container order */ -}}
{{- if $useDependsOn -}}
{{- if empty (dig "dependsOn" nil $containerValues) -}}
{{- $_ := set $graph $key ( list ) -}}
{{- else if kindIs "string" $containerValues.dependsOn -}}
{{- $_ := set $graph $key ( list $containerValues.dependsOn ) -}}
{{- else if kindIs "slice" $containerValues.dependsOn -}}
{{- $_ := set $graph $key $containerValues.dependsOn -}}
{{- end -}}
{{- else -}}
{{- /* TODO: Remove this logic after "order" removal in v3 */ -}}
{{- $containerOrder := (dig "order" 99 $containerValues) -}}
{{- $_ := set $graph $key $containerOrder -}}
{{- if empty (dig "dependsOn" nil $containerValues) -}}
{{- $_ := set $graph $key ( list ) -}}
{{- else if kindIs "string" $containerValues.dependsOn -}}
{{- $_ := set $graph $key ( list $containerValues.dependsOn ) -}}
{{- else if kindIs "slice" $containerValues.dependsOn -}}
{{- $_ := set $graph $key $containerValues.dependsOn -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- /* Process graph */ -}}
{{- if $useDependsOn -}}
{{- $args := dict "graph" $graph "out" list -}}
{{- include "bjw-s.common.lib.kahn" $args -}}
{{- $args := dict "graph" $graph "out" list -}}
{{- include "bjw-s.common.lib.kahn" $args -}}
{{- range $name := $args.out -}}
{{- $containerItem := get $renderedContainers $name -}}
{{- $containers = append $containers $containerItem -}}
{{- end -}}
{{- else -}}
{{- /* TODO: Remove this logic after "order" removal in v3 */ -}}
{{- $orderedContainers := dict -}}
{{- range $key, $order := $graph -}}
{{- $containerItem := get $renderedContainers $key -}}
{{- $_ := set $orderedContainers (printf "%v-%s" $order $key) $containerItem -}}
{{- end -}}
{{- range $key, $containerValues := $orderedContainers -}}
{{- $containers = append $containers $containerValues -}}
{{- end -}}
{{- range $name := $args.out -}}
{{- $containerItem := get $renderedContainers $name -}}
{{- $containers = append $containers $containerItem -}}
{{- end -}}
{{- if not (empty $containers) -}}

View file

@ -9,7 +9,7 @@ Returns the value for annotations
{{- $annotations := dict -}}
{{- /* Set to the default if it is set */ -}}
{{- $defaultOption := get $rootContext.Values.defaultPodOptions "annotations" -}}
{{- $defaultOption := get (default dict $rootContext.Values.defaultPodOptions) "annotations" -}}
{{- if not (empty $defaultOption) -}}
{{- $annotations = merge $defaultOption $annotations -}}
{{- end -}}

View file

@ -17,7 +17,7 @@ Returns the value for labels
{{- end -}}
{{- /* Set to the default if it is set */ -}}
{{- $defaultOption := get $rootContext.Values.defaultPodOptions "labels" -}}
{{- $defaultOption := get (default dict $rootContext.Values.defaultPodOptions) "labels" -}}
{{- if not (empty $defaultOption) -}}
{{- $labels = merge $defaultOption $labels -}}
{{- end -}}

View file

@ -12,7 +12,8 @@ Convert Service values to an object
{{- if $objectValues.nameOverride -}}
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}}
{{- else -}}
{{- if not $objectValues.primary -}}
{{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if and (not $objectValues.primary) (gt 1 (len $enabledServices)) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}