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

@ -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 -}}