feat(common): Release v3.3.0 (#335)

This commit is contained in:
Bernd Schorgers 2024-07-29 14:50:49 +02:00 committed by GitHub
parent 040eb7b9d2
commit 74f3170cec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 386 additions and 10 deletions

View file

@ -0,0 +1,37 @@
{{/*
This template serves as a blueprint for all raw resource objects that are created
within the common library.
*/}}
{{- define "bjw-s.common.class.rawResource" -}}
{{- $rootContext := .rootContext -}}
{{- $resourceObject := .object -}}
{{- $labels := merge
($resourceObject.labels | default dict)
(include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml)
-}}
{{- $annotations := merge
($resourceObject.annotations | default dict)
(include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml)
-}}
---
apiVersion: {{ $resourceObject.apiVersion }}
kind: {{ $resourceObject.kind }}
metadata:
name: {{ $resourceObject.name }}
{{- with $labels }}
labels:
{{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }}
{{- end }}
{{- with $annotations }}
annotations:
{{- range $key, $value := . }}
{{- printf "%s: %s" $key (tpl $value $rootContext | toYaml ) | nindent 4 }}
{{- end }}
{{- end }}
{{- with $resourceObject.spec }}
{{- tpl (toYaml .) $rootContext | nindent 0 }}
{{- end }}
{{- end -}}

View file

@ -93,7 +93,7 @@ spec:
protocol: TCP
{{- end }}
name: {{ $name }}
{{- if (and (eq $svcType "NodePort") (not (empty $port.nodePort))) }}
{{- if (not (empty $port.nodePort)) }}
nodePort: {{ $port.nodePort }}
{{ end }}
{{- if (not (empty $port.appProtocol)) }}

View file

@ -47,6 +47,9 @@ spec:
app.kubernetes.io/component: {{ $statefulsetObject.identifier }}
{{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }}
serviceName: {{ include "bjw-s.common.lib.chart.names.fullname" $rootContext }}
{{- with (dig "statefulset" "persistentVolumeClaimRetentionPolicy" nil $statefulsetObject) }}
persistentVolumeClaimRetentionPolicy: {{ . | toYaml | nindent 4 }}
{{- end }}
template:
metadata:
{{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $statefulsetObject)) }}

View file

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

View file

@ -0,0 +1,7 @@
{{/*
Validate raw resource values
*/}}
{{- define "bjw-s.common.lib.rawResource.validate" -}}
{{- $rootContext := .rootContext -}}
{{- $resourceObject := .object -}}
{{- end -}}

View file

@ -0,0 +1,27 @@
{{/*
Convert raw resource values to an object
*/}}
{{- define "bjw-s.common.lib.rawResource.valuesToObject" -}}
{{- $rootContext := .rootContext -}}
{{- $identifier := .id -}}
{{- $objectValues := .values -}}
{{- /* Determine and inject the raw resource name */ -}}
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}}
{{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}}
{{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}}
{{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}}
{{- /* Return the raw resource object */ -}}
{{- $objectValues | toYaml -}}
{{- end -}}

View file

@ -16,4 +16,5 @@ Secondary entrypoint and primary loader for the common chart
{{- include "bjw-s.common.render.configMaps" . | nindent 0 -}}
{{- include "bjw-s.common.render.secrets" . | nindent 0 -}}
{{- include "bjw-s.common.render.networkpolicies" . | nindent 0 -}}
{{- include "bjw-s.common.render.rawResources" . | nindent 0 -}}
{{- end -}}

View file

@ -0,0 +1,26 @@
{{/*
Renders other arbirtrary objects required by the chart.
*/}}
{{- define "bjw-s.common.render.rawResources" -}}
{{- /* Generate pvc as required */ -}}
{{- range $key, $resource := .Values.rawResources -}}
{{- /* Enable by default, but allow override */ -}}
{{- $resourceEnabled := true -}}
{{- if hasKey $resource "enabled" -}}
{{- $resourceEnabled = $resource.enabled -}}
{{- end -}}
{{- if $resourceEnabled -}}
{{- $resourceValues := (mustDeepCopy $resource) -}}
{{- /* Create object from the raw resource values */ -}}
{{- $resourceObject := (include "bjw-s.common.lib.rawResource.valuesToObject" (dict "rootContext" $ "id" $key "values" $resourceValues)) | fromYaml -}}
{{- /* Perform validations on the resource before rendering */ -}}
{{- include "bjw-s.common.lib.rawResource.validate" (dict "rootContext" $ "object" $resourceValues) -}}
{{- /* Include the raw resource class */ -}}
{{- include "bjw-s.common.class.rawResource" (dict "rootContext" $ "object" $resourceValues) | nindent 0 -}}
{{- end -}}
{{- end -}}
{{- end -}}