mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 00:47:04 +02:00
fix(common): Release v3.0.3 (#291)
Co-authored-by: Gabe Cook <gabe565@gmail.com>
This commit is contained in:
parent
a50630fa60
commit
425f4428ab
12 changed files with 164 additions and 33 deletions
17
charts/library/common/templates/lib/chart/_validate.tpl
Normal file
17
charts/library/common/templates/lib/chart/_validate.tpl
Normal file
|
@ -0,0 +1,17 @@
|
|||
{{/*
|
||||
Validate global chart values
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.chart.validate" -}}
|
||||
{{- $rootContext := . -}}
|
||||
|
||||
{{- /* Validate persistence values */ -}}
|
||||
{{- range $persistenceKey, $persistenceValues := .Values.persistence }}
|
||||
{{- /* Make sure that any advancedMounts controller references actually resolve */ -}}
|
||||
{{- range $key, $advancedMount := $persistenceValues.advancedMounts -}}
|
||||
{{- $mountController := include "bjw-s.common.lib.controller.getByIdentifier" (dict "rootContext" $rootContext "id" $key) -}}
|
||||
{{- if empty $mountController -}}
|
||||
{{- fail (printf "No enabled controller found with this identifier. (persistence item: '%s', controller: '%s')" $persistenceKey $key) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,14 @@
|
|||
{{/*
|
||||
Return a controller by its identifier.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.controller.getByIdentifier" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $identifier := .id -}}
|
||||
|
||||
{{- $enabledControllers := include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml -}}
|
||||
{{- $controllerValues := get $enabledControllers $identifier -}}
|
||||
|
||||
{{- if not (empty $controllerValues) -}}
|
||||
{{- include "bjw-s.common.lib.controller.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $controllerValues) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -11,18 +11,27 @@ Return the primary service object for a controller
|
|||
{{- /* Loop over all enabled services */ -}}
|
||||
{{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) }}
|
||||
{{- if $enabledServices -}}
|
||||
{{- /* We are only interested in services for the specified controller */ -}}
|
||||
{{- $enabledServicesForController := dict -}}
|
||||
{{- range $name, $service := $enabledServices -}}
|
||||
{{- /* Determine the Service that has been marked as primary */ -}}
|
||||
{{- if and (hasKey $service "primary") $service.primary -}}
|
||||
{{- $identifier = $name -}}
|
||||
{{- $result = $service -}}
|
||||
{{- if eq $service.controller $controllerIdentifier -}}
|
||||
{{- $_ := set $enabledServicesForController $name $service -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Return the first Service if none has been explicitly marked as primary */ -}}
|
||||
{{- if not $result -}}
|
||||
{{- $identifier = keys $enabledServices | first -}}
|
||||
{{- $result = get $enabledServices $identifier -}}
|
||||
{{- range $name, $service := $enabledServicesForController -}}
|
||||
{{- /* Determine the Service that has been marked as primary */ -}}
|
||||
{{- if $service.primary -}}
|
||||
{{- $identifier = $name -}}
|
||||
{{- $result = $service -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Return the first Service if none has been explicitly marked as primary */ -}}
|
||||
{{- if not $result -}}
|
||||
{{- $firstServiceKey := keys $enabledServicesForController | first -}}
|
||||
{{- $result = get $enabledServicesForController $firstServiceKey -}}
|
||||
{{- $identifier = $result.identifier -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- include "bjw-s.common.lib.service.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $result) -}}
|
||||
|
|
|
@ -9,6 +9,11 @@ Validate Service values
|
|||
{{- fail (printf "controller field is required for Service. (service: %s)" $serviceObject.identifier) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $serviceController := include "bjw-s.common.lib.controller.getByIdentifier" (dict "rootContext" $rootContext "id" $serviceObject.controller) -}}
|
||||
{{- if empty $serviceController -}}
|
||||
{{- fail (printf "No enabled controller found with this identifier. (service: '%s', controller: '%s')" $serviceObject.identifier $serviceObject.controller) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Validate Service type */ -}}
|
||||
{{- $validServiceTypes := (list "ClusterIP" "LoadBalancer" "NodePort" "ExternalName" "ExternalIP") -}}
|
||||
{{- if and $serviceObject.type (not (mustHas $serviceObject.type $validServiceTypes)) -}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue