mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 08:57:04 +02:00
feat(common): Release library 3.7.0 (#377)
Signed-off-by: solidDoWant <fred.heinecke@yahoo.com> Co-authored-by: Patrick Collins <Patricol@users.noreply.github.com> Co-authored-by: Patrick Collins <patrick.collins@gainbridge.io> Co-authored-by: Lawrence Gil <larrywtf609@gmail.com> Co-authored-by: solidDoWant <fred.heinecke@yahoo.com>
This commit is contained in:
parent
aee0d999ba
commit
8b33237e27
32 changed files with 793 additions and 655 deletions
|
@ -39,7 +39,7 @@ spec:
|
|||
app.kubernetes.io/service: {{ tpl $serviceMonitorObject.serviceName $rootContext }}
|
||||
{{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }}
|
||||
{{- end }}
|
||||
endpoints: {{- toYaml $serviceMonitorObject.endpoints | nindent 4 }}
|
||||
endpoints: {{- tpl (toYaml $serviceMonitorObject.endpoints) $rootContext | nindent 4 }}
|
||||
{{- if not (empty $serviceMonitorObject.targetLabels )}}
|
||||
targetLabels:
|
||||
{{- toYaml $serviceMonitorObject.targetLabels | nindent 4 }}
|
||||
|
|
|
@ -4,8 +4,28 @@ Validate configMap values
|
|||
{{- define "bjw-s.common.lib.configMap.validate" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $configMapValues := .object -}}
|
||||
{{- $identifier := .id -}}
|
||||
|
||||
{{- if empty $configMapValues -}}
|
||||
{{- fail (printf "There was an error loading ConfigMap: %s. If it was automatically generated from a folder verify that files are properly flagged as `binary` or `escaped`" $identifier) -}}
|
||||
{{- end -}}
|
||||
{{- if and (empty (get $configMapValues "data")) (empty (get $configMapValues "binaryData")) -}}
|
||||
{{- fail (printf "No data or binaryData specified for configMap. (configMap: %s)" $configMapValues.identifier) }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Validate configMap from folder values
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.configMap.fromFolder.validate" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $basePath := required "If you're using `configMapsFromFolder` you need to specify a `basePath` key" .basePath -}}
|
||||
{{ $topLevelFolders := dict}}
|
||||
{{- range $path, $_ := $rootContext.Files.Glob (printf "%s/*/*" $basePath) -}}
|
||||
{{- $_ := set $topLevelFolders (dir $path) "" -}}
|
||||
{{- end -}}
|
||||
{{- $topLevelFoldersList := keys $topLevelFolders | sortAlpha -}}
|
||||
{{- if empty $topLevelFoldersList -}}
|
||||
{{- fail (printf "No configMaps found in the folder %s" $basePath) }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -54,7 +54,13 @@ Probes used by the container.
|
|||
"scheme" $probeType
|
||||
)
|
||||
-}}
|
||||
{{- else }}
|
||||
{{- else if (eq $probeType "GRPC") -}}
|
||||
{{- $probeHeader = "grpc" -}}
|
||||
{{- $_ := set $probeDefinition $probeHeader dict -}}
|
||||
{{- if $probeValues.service -}}
|
||||
{{- $_ := set (index $probeDefinition $probeHeader) "service" $probeValues.service -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $probeHeader = "tcpSocket" -}}
|
||||
{{- $_ := set $probeDefinition $probeHeader dict -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -31,6 +31,9 @@ hostPID: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "
|
|||
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostUsers")) }}
|
||||
hostUsers: {{ . | trim }}
|
||||
{{- end -}}
|
||||
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "shareProcessNamespace")) }}
|
||||
shareProcessNamespace: {{ . | trim }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
dnsPolicy: {{ include "bjw-s.common.lib.pod.field.dnsPolicy" (dict "ctx" $ctx) | trim }}
|
||||
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "dnsConfig")) }}
|
||||
|
@ -52,7 +55,7 @@ restartPolicy: {{ . | trim }}
|
|||
nodeSelector: {{ . | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "affinity")) }}
|
||||
affinity: {{ . | nindent 2 }}
|
||||
affinity: {{- tpl . $rootContext | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "topologySpreadConstraints")) }}
|
||||
topologySpreadConstraints: {{ . | nindent 2 }}
|
||||
|
|
|
@ -8,13 +8,13 @@ Secondary entrypoint and primary loader for the common chart
|
|||
{{- /* Build the templates */ -}}
|
||||
{{- include "bjw-s.common.render.pvcs" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.serviceAccount" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.configMaps.fromFolder" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.configMaps" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.controllers" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.services" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.ingresses" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.serviceMonitors" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.routes" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.configMaps.fromFiles" . | nindent 0 -}}
|
||||
{{- 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 -}}
|
||||
|
|
|
@ -17,9 +17,8 @@ Renders the configMap objects required by the chart.
|
|||
|
||||
{{- /* Create object from the raw configMap values */ -}}
|
||||
{{- $configMapObject := (include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $configMapValues)) | fromYaml -}}
|
||||
|
||||
{{- /* Perform validations on the configMap before rendering */ -}}
|
||||
{{- include "bjw-s.common.lib.configMap.validate" (dict "rootContext" $ "object" $configMapObject) -}}
|
||||
{{- include "bjw-s.common.lib.configMap.validate" (dict "rootContext" $ "object" $configMapObject "id" $key) -}}
|
||||
|
||||
{{/* Include the configMap class */}}
|
||||
{{- include "bjw-s.common.class.configMap" (dict "rootContext" $ "object" $configMapObject) | nindent 0 -}}
|
||||
|
@ -30,36 +29,57 @@ Renders the configMap objects required by the chart.
|
|||
{{/*
|
||||
Renders configMap objects required by the chart from a folder in the repo's path.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.render.configMaps.fromFiles" -}}
|
||||
{{- $rootValues := .Values -}}
|
||||
{{- define "bjw-s.common.render.configMaps.fromFolder" -}}
|
||||
|
||||
{{/* Generate a list of unique top level folders */}}
|
||||
{{ $topLevelFolders := dict}}
|
||||
{{- range $path, $_ := .Files.Glob (printf "%s/*/*" .Values.configMapsFromFolderBasePath) -}}
|
||||
{{- $_ := set $topLevelFolders (dir $path) "" -}}
|
||||
{{- end -}}
|
||||
{{- $top_level_folder_list := keys $topLevelFolders | sortAlpha -}}
|
||||
{{/* Iterate over the top level folders */}}
|
||||
{{ range $path := $top_level_folder_list }}
|
||||
{{- $filesContentNoFormat := ($.Files.Glob (printf "%s/*" $path)) -}}
|
||||
{{- $filesContent := dict -}}
|
||||
{{- $binaryFilesContent := dict -}}
|
||||
{{- range $file_name, $content := $filesContentNoFormat -}}
|
||||
{{- $key := base $file_name -}}
|
||||
{{- if contains ".escape" $key -}}
|
||||
{{- $key := $key | replace ".escape" "" -}}
|
||||
{{- $filesContent = merge $filesContent (dict $key (($.Files.Get $file_name) | replace "{{" "{{ `{{` }}")) -}}
|
||||
{{- else if contains ".binary" $key -}}
|
||||
{{- $key := $key | replace ".binary" "" -}}
|
||||
{{- $binaryFilesContent = merge $binaryFilesContent (dict $key ($.Files.Get $file_name | b64enc )) -}}
|
||||
{{- else -}}
|
||||
{{- $filesContent = merge $filesContent (dict $key ($.Files.Get $file_name)) -}}
|
||||
{{- end -}}
|
||||
{{- $valuesCopy := .Values -}}
|
||||
{{- $configMapsFromFolder := .Values.configMapsFromFolder | default dict -}}
|
||||
{{- $configMapsFromFolderEnabled := dig "enabled" false $configMapsFromFolder -}}
|
||||
|
||||
{{- if $configMapsFromFolderEnabled -}}
|
||||
{{- /* Perform validations before rendering */ -}}
|
||||
{{- include "bjw-s.common.lib.configMap.fromFolder.validate" (dict "rootContext" $ "basePath" $configMapsFromFolder.basePath) -}}
|
||||
{{- $basePath := $configMapsFromFolder.basePath -}}
|
||||
{{/* Generate a list of unique top level folders */}}
|
||||
{{ $topLevelFolders := dict}}
|
||||
{{- range $path, $_ := .Files.Glob (printf "%s/*/*" $basePath) -}}
|
||||
{{- $_ := set $topLevelFolders (dir $path) "" -}}
|
||||
{{- end -}}
|
||||
{{- $top_level_folder_list := keys $topLevelFolders | sortAlpha -}}
|
||||
{{/* Iterate over the top level folders */}}
|
||||
{{ range $path := $top_level_folder_list }}
|
||||
{{- $folder := base $path -}}
|
||||
{{- $configMapData := dict -}}
|
||||
{{- $configMapBinaryData := dict -}}
|
||||
{{- $allFilesContent := ($.Files.Glob (printf "%s/*" $path)) -}}
|
||||
|
||||
{{- $configMapValues := dict "enabled" true "labels" dict "annotations" dict "data" $filesContent "binaryData" $binaryFilesContent -}}
|
||||
{{- $existingConfigMaps := (get $rootValues "configMaps"| default dict) -}}
|
||||
{{- $mergedConfigMaps := deepCopy $existingConfigMaps | merge (dict (base $path) $configMapValues) -}}
|
||||
{{- $rootValues := merge $rootValues (dict "configMaps" $mergedConfigMaps) -}}
|
||||
{{- $configMapAnnotations := dig "configMapsOverrides" $folder "annotations" dict $configMapsFromFolder -}}
|
||||
{{- $configMapLabels := dig "configMapsOverrides" $folder "labels" dict $configMapsFromFolder -}}
|
||||
{{- $configMapForceRename := dig "configMapsOverrides" $folder "forceRename" nil $configMapsFromFolder -}}
|
||||
{{- range $file_name, $content := $allFilesContent -}}
|
||||
{{- $file := base $file_name -}}
|
||||
{{- $fileOverride := dig "configMapsOverrides" $folder "fileAttributeOverrides" $file nil $configMapsFromFolder -}}
|
||||
{{- $fileContent := $.Files.Get $file_name -}}
|
||||
{{- if not $fileOverride.exclude -}}
|
||||
{{- if $fileOverride.binary -}}
|
||||
{{- $fileContent = $fileContent | b64enc -}}
|
||||
{{- $configMapBinaryData = merge $configMapBinaryData (dict $file $fileContent) -}}
|
||||
{{- else if $fileOverride.escaped -}}
|
||||
{{- $fileContent = $fileContent | replace "{{" "{{ `{{` }}" -}}
|
||||
{{- $configMapData = merge $configMapData (dict $file $fileContent) -}}
|
||||
{{- else -}}
|
||||
{{- $configMapData = merge $configMapData (dict $file $fileContent) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ end }}
|
||||
|
||||
{{- $configMapValues := dict "enabled" true "forceRename" $configMapForceRename "labels" $configMapLabels "annotations" $configMapAnnotations "data" $configMapData "binaryData" $configMapBinaryData -}}
|
||||
{{- $configMapObject := (include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $ "id" $folder "values" $configMapValues)) | fromYaml -}}
|
||||
{{/* Append it to .Values.configMaps so it can be created by "bjw-s.common.render.configMaps" and fetched by identifier */}}
|
||||
{{- $existingConfigMaps := (get $valuesCopy "configMaps"| default dict) -}}
|
||||
{{- $mergedConfigMaps := deepCopy $existingConfigMaps | merge (dict (base $path) $configMapValues) -}}
|
||||
{{- $valuesCopy := merge $valuesCopy (dict "configMaps" $mergedConfigMaps) -}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue