mirror of
https://github.com/truenas/charts.git
synced 2026-06-17 07:27:44 +08:00
fix test
This commit is contained in:
@@ -84,29 +84,26 @@ memory: {{ . }}
|
||||
{{- $value := .value -}}
|
||||
{{- $required := .required -}}
|
||||
|
||||
{{- with (toString $value) -}} {{/* Stringify to avoid falsy values evaluating as false */}}
|
||||
|
||||
{{- if $required -}} {{/* If requred and it's empty fail (requests are requried) */}}
|
||||
{{- if eq . "<nil>" -}}
|
||||
{{- fail (printf "<resources.%s.%s> cannot be empty." $object $key) -}}
|
||||
{{- end -}}
|
||||
{{- if $required -}} {{/* If requred and it's empty fail (requests are requried) */}}
|
||||
{{- if kindIs "invalid" $value -}}
|
||||
{{- fail (printf "<resources.%s.%s> cannot be empty." $object $key) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* If it's not null validate input */}}
|
||||
{{- if ne . "<nil>" -}} {{/* Limits can be null, means "no limit" */}}
|
||||
{{- if eq $key "cpu" -}}
|
||||
{{/* https://regex101.com/r/D4HouI/1 */}}
|
||||
{{- if not (mustRegexMatch "^(0\\.[1-9]|[1-9][0-9]*)(\\.[0-9]|m?)$" .) -}}
|
||||
{{- fail (printf "<resources.%s.%s> has invalid format in value (%s). Valid formats are (Plain Integer eg. 1) (Float eg. 0.5) (Milicpu 500m)." $object $key .) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- else if eq $key "memory" -}}
|
||||
{{/* https://regex101.com/r/NNPV2D/1 */}}
|
||||
{{- if not (mustRegexMatch "^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$" .) -}}
|
||||
{{- fail (printf "<resources.%s.%s> has invalid format in value (%s). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6)." $object $key .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
{{/* If it's not null validate input */}}
|
||||
{{- if not (kindIs "invalid" $value) -}} {{/* Limits can be null, means "no limit" */}}
|
||||
{{- if eq $key "cpu" -}}
|
||||
{{/* https://regex101.com/r/D4HouI/1 */}}
|
||||
{{- if not (mustRegexMatch "^(0\\.[1-9]|[1-9][0-9]*)(\\.[0-9]|m?)$" (toString $value)) -}}
|
||||
{{- fail (printf "<resources.%s.%s> has invalid format in value (%v). Valid formats are (Plain Integer eg. 1) (Float eg. 0.5) (Milicpu 500m)." $object $key $value) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- else if eq $key "memory" -}}
|
||||
{{/* https://regex101.com/r/NNPV2D/1 */}}
|
||||
{{- if not (mustRegexMatch "^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$" (toString $value)) -}}
|
||||
{{- fail (printf "<resources.%s.%s> has invalid format in value (%v). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6)." $object $key $value) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
@@ -83,13 +83,13 @@ The reason is not splitted, is that on one of the places needs a combo of all va
|
||||
{{- fail (printf "<privileged> key has value (%v). But it must be boolean." $returnValue.privileged) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq (toString $returnValue.runAsUser) "<nil>" -}}
|
||||
{{- if kindIs "invalid" $returnValue.runAsUser -}}
|
||||
{{- fail (printf "<runAsUser> key cannot be empty. Set a value or remove the key for the default (%v) to take effect." $defaultSecCont.runAsUser) -}}
|
||||
{{- else if not (mustHas (kindOf $returnValue.runAsUser) (list "int" "float64")) -}}
|
||||
{{- fail (printf "<runAsUser> key has value of (%q). But must be an int." $returnValue.runAsUser) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq (toString $returnValue.runAsGroup) "<nil>" -}}
|
||||
{{- if kindIs "invalid" $returnValue.runAsGroup -}}
|
||||
{{- fail (printf "<runAsGroup> key cannot be empty. Set a value or remove the key for the default (%v) to take effect." $defaultSecCont.runAsGroup) -}}
|
||||
{{- else if not (mustHas (kindOf $returnValue.runAsGroup) (list "int" "float64")) -}}
|
||||
{{- fail (printf "<runAsGroup> key has value of (%q). But must be an int." $returnValue.runAsGroup) -}}
|
||||
@@ -227,7 +227,7 @@ The reason is not splitted, is that on one of the places needs a combo of all va
|
||||
{{- fail (printf "<UMASK> key must be a string, so the format is kept intact.") -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq (toString $returnValue.PUID) "<nil>" -}}
|
||||
{{- if kindIs "invalid" $returnValue.PUID -}}
|
||||
{{- fail (printf "<PUID> key cannot be empty. Set a value or remove the key for the default (%v) to take effect." $defaultSecEnvs.PUID) -}}
|
||||
{{- else if not (mustHas (kindOf $returnValue.PUID) (list "int" "float64")) -}}
|
||||
{{- fail (printf "<PUID> key has value of (%q). But must be an int." $returnValue.PUID) -}}
|
||||
|
||||
Reference in New Issue
Block a user