mirror of
https://github.com/truenas/charts.git
synced 2026-04-04 11:20:18 +08:00
* Adapt charts CI and improve/fix common * add check on permissions contaienr * add postgres template * update comments * Update create_app.sh * add check * update script * auto gen item.yaml from Chart,yaml * rename readme on dest * duplicate readme from the same source * correct comment * reoder * remove extra space * keep both README and app-readme * update regex, to also allow 2 letter names, which is also valid * No need to check host network if there aren't any pod values * use same pattern as the pod.name label (not prepending release-name * update deps * add chart dirs to ci * Add a validation to check if there is any yaml errors after merging files * update charts path on ci * common/1.0.0/ -> common/ * update common-test dep path * temp update create_app script * make permissions container name configurable, incase we want to change order of execution * update naming convention * fix typo and a missed name change * do not allow `--` in names
132 lines
4.1 KiB
Smarty
132 lines
4.1 KiB
Smarty
{{/* Service Validation */}}
|
|
{{/* Call this template:
|
|
{{ include "ix.v1.common.lib.service.validation" (dict "objectData" $objectData) -}}
|
|
objectData:
|
|
rootCtx: The root context of the chart.
|
|
objectData: The service object.
|
|
*/}}
|
|
|
|
{{- define "ix.v1.common.lib.service.validation" -}}
|
|
{{- $rootCtx := .rootCtx -}}
|
|
{{- $objectData := .objectData -}}
|
|
|
|
{{- if and $objectData.targetSelector (not (kindIs "string" $objectData.targetSelector)) -}}
|
|
{{- fail (printf "Service - Expected <targetSelector> to be [string], but got [%s]" (kindOf $objectData.targetSelector)) -}}
|
|
{{- end -}}
|
|
|
|
{{- $svcTypes := (list "ClusterIP" "NodePort") -}}
|
|
{{- if and $objectData.type (not (mustHas $objectData.type $svcTypes)) -}}
|
|
{{- fail (printf "Service - Expected <type> to be one of [%s] but got [%s]" (join ", " $svcTypes) $objectData.type) -}}
|
|
{{- end -}}
|
|
|
|
{{- $hasEnabledPort := false -}}
|
|
{{- range $name, $port := $objectData.ports -}}
|
|
{{- if $port.enabled -}}
|
|
{{- $hasEnabledPort = true -}}
|
|
|
|
{{- if and $port.targetSelector (not (kindIs "string" $port.targetSelector)) -}}
|
|
{{- fail (printf "Service - Expected <port.targetSelector> to be [string], but got [%s]" (kindOf $port.targetSelector)) -}}
|
|
{{- end -}}
|
|
|
|
{{- if not $port.port -}}
|
|
{{- fail (printf "Service - Expected non-empty <port.port>") -}}
|
|
{{- end -}}
|
|
|
|
{{- $protocolTypes := (list "tcp" "udp" "http" "https") -}}
|
|
{{- if $port.protocol -}}
|
|
{{- if not (mustHas (tpl $port.protocol $rootCtx) $protocolTypes) -}}
|
|
{{- fail (printf "Service - Expected <port.protocol> to be one of [%s] but got [%s]" (join ", " $protocolTypes) $port.protocol) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- if not $hasEnabledPort -}}
|
|
{{- fail "Service - Expected enabled service to have at least one port" -}}
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{/* Service Primary Validation */}}
|
|
{{/* Call this template:
|
|
{{ include "ix.v1.common.lib.service.primaryValidation" $ -}}
|
|
*/}}
|
|
|
|
{{- define "ix.v1.common.lib.service.primaryValidation" -}}
|
|
|
|
{{/* Initialize values */}}
|
|
{{- $hasPrimary := false -}}
|
|
{{- $hasEnabled := false -}}
|
|
|
|
{{- range $name, $service := .Values.service -}}
|
|
|
|
{{/* If service is enabled */}}
|
|
{{- if $service.enabled -}}
|
|
{{- $hasEnabled = true -}}
|
|
|
|
{{/* And service is primary */}}
|
|
{{- if and (hasKey $service "primary") ($service.primary) -}}
|
|
{{/* Fail if there is already a primary service */}}
|
|
{{- if $hasPrimary -}}
|
|
{{- fail "Service - Only one service can be primary" -}}
|
|
{{- end -}}
|
|
|
|
{{- $hasPrimary = true -}}
|
|
|
|
{{- include "ix.v1.common.lib.servicePort.primaryValidation" (dict "objectData" $service.ports) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/* Require at least one primary service, if any enabled */}}
|
|
{{- if and $hasEnabled (not $hasPrimary) -}}
|
|
{{- fail "Service - At least one enabled service must be primary" -}}
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{/* Service Port Primary Validation */}}
|
|
{{/* Call this template:
|
|
{{ include "ix.v1.common.lib.service.primaryValidation" (dict "objectData" $objectData -}}
|
|
objectData:
|
|
The ports of the service.
|
|
*/}}
|
|
|
|
{{- define "ix.v1.common.lib.servicePort.primaryValidation" -}}
|
|
{{- $objectData := .objectData -}}
|
|
|
|
{{/* Initialize values */}}
|
|
{{- $hasPrimary := false -}}
|
|
{{- $hasEnabled := false -}}
|
|
|
|
{{- range $name, $port := $objectData -}}
|
|
|
|
{{/* If service is enabled */}}
|
|
{{- if $port.enabled -}}
|
|
{{- $hasEnabled = true -}}
|
|
|
|
{{/* And service is primary */}}
|
|
{{- if and (hasKey $port "primary") ($port.primary) -}}
|
|
|
|
{{/* Fail if there is already a primary port */}}
|
|
{{- if $hasPrimary -}}
|
|
{{- fail "Service - Only one port per service can be primary" -}}
|
|
{{- end -}}
|
|
|
|
{{- $hasPrimary = true -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/* Require at least one primary service, if any enabled */}}
|
|
{{- if and $hasEnabled (not $hasPrimary) -}}
|
|
{{- fail "Service - At least one enabled port in service must be primary" -}}
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|