mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 00:47:04 +02:00
feat(common): Release version 2.0.0-beta.1 (#173)
This commit is contained in:
parent
19767d668c
commit
7b6ee00be6
189 changed files with 3110 additions and 3023 deletions
37
charts/library/common/templates/lib/service/_validate.tpl
Normal file
37
charts/library/common/templates/lib/service/_validate.tpl
Normal file
|
@ -0,0 +1,37 @@
|
|||
{{/*
|
||||
Validate Service values
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.service.validate" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $serviceObject := .object -}}
|
||||
|
||||
{{- if empty (get $serviceObject "controller") -}}
|
||||
{{- fail (printf "controller is required for Service. (service: %s)" $serviceObject.identifier) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Validate Service type */ -}}
|
||||
{{- $validServiceTypes := (list "ClusterIP" "LoadBalancer" "NodePort" "ExternalName" "ExternalIP") -}}
|
||||
{{- if and $serviceObject.type (not (mustHas $serviceObject.type $validServiceTypes)) -}}
|
||||
{{- fail (
|
||||
printf "invalid service type \"%s\" for Service with key \"%s\". Allowed values are [%s]"
|
||||
$serviceObject.type
|
||||
$serviceObject.identifier
|
||||
(join ", " $validServiceTypes)
|
||||
) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if ne $serviceObject.type "ExternalName" -}}
|
||||
{{- $enabledPorts := include "bjw-s.common.lib.service.enabledPorts" (dict "rootContext" $rootContext "serviceObject" $serviceObject) | fromYaml }}
|
||||
{{- /* Validate at least one port is enabled */ -}}
|
||||
{{- if not $enabledPorts -}}
|
||||
{{- fail (printf "no ports are enabled for Service with key \"%s\"" $serviceObject.identifier) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- range $name, $port := $enabledPorts -}}
|
||||
{{- /* Validate a port number is configured */ -}}
|
||||
{{- if not $port.port -}}
|
||||
{{- fail (printf "no port number is configured for port \"%s\" under Service with key \"%s\"" $name $serviceObject.identifier) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
Loading…
Add table
Add a link
Reference in a new issue