feat(common): Release version 2.0.0-beta.1 (#173)

This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2023-09-13 11:24:23 +02:00 committed by GitHub
parent 19767d668c
commit 7b6ee00be6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
189 changed files with 3110 additions and 3023 deletions

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