mirror of
https://github.com/truenas/charts.git
synced 2026-06-16 23:19:15 +08:00
simplify error messages
This commit is contained in:
@@ -115,7 +115,7 @@ tests:
|
||||
primary: true
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Service - Expected service's <targetSelector> to be [string], but got [map]
|
||||
errorMessage: Service - Expected <targetSelector> to be [string], but got [map]
|
||||
|
||||
- it: should fail with container targetSelector not a string
|
||||
set:
|
||||
@@ -131,7 +131,7 @@ tests:
|
||||
container: not-a-string
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Service - Expected port's <targetSelector> to be [string], but got [map]
|
||||
errorMessage: Service - Expected <port.targetSelector> to be [string], but got [map]
|
||||
|
||||
- it: should fail with selected pod not defined
|
||||
set:
|
||||
@@ -188,4 +188,20 @@ tests:
|
||||
protocol: not-a-protocol
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Service - Expected port's protocol to be one of [TCP, UDP, HTTP, HTTPS] but got [not-a-protocol]
|
||||
errorMessage: Service - Expected <port.protocol> to be one of [TCP, UDP, HTTP, HTTPS] but got [not-a-protocol]
|
||||
|
||||
- it: should fail with invalid service type
|
||||
set:
|
||||
service:
|
||||
service-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: not-a-type
|
||||
ports:
|
||||
port-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
protocol: not-a-protocol
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Service - Expected <type> to be one of [ClusterIP, LoadBalancer, NodePort, ExternalName, ExternalIP] but got [not-a-type]
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
# Service
|
||||
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :------------------------------------ | :-------: | :------: | :----------------: | :---------: | :---------------------------------------------------------------------- |
|
||||
| service | `dict` | ❌ | ❌ | `{}` | Define the service as dicts |
|
||||
| service.[service-name] | `dict` | ✅ | ❌ | `{}` | Holds service definition |
|
||||
| service.[service-name].enabled | `boolean` | ✅ | ❌ | `false` | Enables or Disables the service |
|
||||
| service.[service-name].labels | `dict` | ❌ | ✅ (On value only) | `{}` | Additional labels for service |
|
||||
| service.[service-name].annotations | `dict` | ❌ | ✅ (On value only) | `{}` | Additional annotations for service |
|
||||
| service.[service-name].type | `string` | ❌ | ✅ | `ClusterIP` | Define the service type |
|
||||
| service.[service-name].sharedKey | `string` | ❌ | ✅ | `$FullName` | Custom Shared Key for MetalLB Annotation |
|
||||
| service.[service-name].targetSelector | `string` | ❌ | ✅ | `""` | Define the pod to link the service, by default will use the primary pod |
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :------------------------------------ | :-------: | :------: | :----------------: | :---------: | :------------------------------------------------------------------------------------ |
|
||||
| service | `dict` | ❌ | ❌ | `{}` | Define the service as dicts |
|
||||
| service.[service-name] | `dict` | ✅ | ❌ | `{}` | Holds service definition |
|
||||
| service.[service-name].enabled | `boolean` | ✅ | ❌ | `false` | Enables or Disables the service |
|
||||
| service.[service-name].labels | `dict` | ❌ | ✅ (On value only) | `{}` | Additional labels for service |
|
||||
| service.[service-name].annotations | `dict` | ❌ | ✅ (On value only) | `{}` | Additional annotations for service |
|
||||
| service.[service-name].type | `string` | ❌ | ✅ | `ClusterIP` | Define the service type (ClusterIP, LoadBalancer, NodePort, ExternalIP, ExternalName) |
|
||||
| service.[service-name].sharedKey | `string` | ❌ | ✅ | `$FullName` | Custom Shared Key for MetalLB Annotation |
|
||||
| service.[service-name].targetSelector | `string` | ❌ | ✅ | `""` | Define the pod to link the service, by default will use the primary pod |
|
||||
| service.[service-name].ports | `list` | ✅ | ❌ | `{}` | Define the ports of the service |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -38,8 +38,9 @@ objectData: The object data to be used to render the Pod.
|
||||
{{- $policy = "ClusterFirstWithHostNet" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (mustHas $policy (list "ClusterFirst" "ClusterFirstWithHostNet" "Default" "None")) -}}
|
||||
{{- fail (printf "Expected <dnsPolicy> to be one of [ClusterFirst, ClusterFirstWithHostNet, Default, None], but got [%s]" $policy) -}}
|
||||
{{- $policies := (list "ClusterFirst" "ClusterFirstWithHostNet" "Default" "None") -}}
|
||||
{{- if not (mustHas $policy $policies) -}}
|
||||
{{- fail (printf "Expected <dnsPolicy> to be one of [%s], but got [%s]" (join ", " $policies) $policy) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* When policy is set to None all keys are required */}}
|
||||
|
||||
@@ -20,11 +20,13 @@ objectData: The object data to be used to render the Pod.
|
||||
{{- $policy = tpl . $rootCtx -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if not (mustHas $policy (list "Always" "Never" "OnFailure")) -}}
|
||||
{{- fail (printf "Expected <restartPolicy to be one of [Never, Always, OnFailure] but got [%s]" $policy) -}}
|
||||
{{- $policies := (list "Never" "Always" "OnFailure") -}}
|
||||
{{- if not (mustHas $policy $policies) -}}
|
||||
{{- fail (printf "Expected <restartPolicy to be one of [%s] but got [%s]" (join ", " $policies) $policy) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (ne "Always" $policy) (mustHas $objectData.type (list "Deployment" "DaemonSet" "StatefulSet")) -}}
|
||||
{{- $types := (list "Deployment" "DaemonSet" "StatefulSet") -}}
|
||||
{{- if and (ne "Always" $policy) (mustHas $objectData.type $types) -}}
|
||||
{{- fail (printf "Expected <restartPolicy to be [Always] for [%s] but got [%s]" $objectData.type $policy) -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
@@ -28,8 +28,9 @@ objectData: The object data to be used to render the Pod.
|
||||
{{- $effect := (tpl (.effect | default "") $rootCtx) -}}
|
||||
{{- $tolSeconds := .tolerationSeconds -}}
|
||||
|
||||
{{- if not (mustHas $operator (list "Exists" "Equal")) -}}
|
||||
{{- fail (printf "Expected <tolerations.operator> to be one of [Exists, Equal] but got [%s]" $operator) -}}
|
||||
{{- $operators := (list "Exists" "Equal") -}}
|
||||
{{- if not (mustHas $operator $operators) -}}
|
||||
{{- fail (printf "Expected <tolerations.operator> to be one of [%s] but got [%s]" (join ", " $operators) $operator) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (eq $operator "Equal") (or (not $key) (not $value)) -}}
|
||||
@@ -40,8 +41,9 @@ objectData: The object data to be used to render the Pod.
|
||||
{{- fail (printf "Expected empty <tolerations.value> with <tolerations.operator> set to [Exists], but got [%s]" $value) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and $effect (not (mustHas $effect (list "NoExecute" "NoSchedule" "PreferNoSchedule"))) -}}
|
||||
{{- fail (printf "Expected <tolerations.effect> to be one of [NoExecute, NoSchedule, PreferNoSchedule], but got [%s]" $effect) -}}
|
||||
{{- $effects := (list "NoExecute" "NoSchedule" "PreferNoSchedule") -}}
|
||||
{{- if and $effect (not (mustHas $effect $effects)) -}}
|
||||
{{- fail (printf "Expected <tolerations.effect> to be one of [%s], but got [%s]" (join ", " $effects) $effect) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (not (kindIs "invalid" $tolSeconds)) (not (mustHas (kindOf $tolSeconds) (list "int" "float64"))) -}}
|
||||
|
||||
@@ -13,8 +13,9 @@ objectData:
|
||||
{{- if $objectData.concurrencyPolicy -}}
|
||||
{{- $concurrencyPolicy := $objectData.concurrencyPolicy -}}
|
||||
|
||||
{{- if not (mustHas $concurrencyPolicy (list "Allow" "Forbid" "Replace")) -}}
|
||||
{{- fail (printf "CronJob - Expected <concurrencyPolicy> to be one of [Allow, Forbid, Replace], but got [%v]" $concurrencyPolicy) -}}
|
||||
{{- $policies := (list "Allow" "Forbid" "Replace") -}}
|
||||
{{- if not (mustHas $concurrencyPolicy $policies) -}}
|
||||
{{- fail (printf "CronJob - Expected <concurrencyPolicy> to be one of [%s], but got [%v]" (join ", " $policies) $concurrencyPolicy) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
@@ -12,8 +12,9 @@ objectData:
|
||||
{{- if $objectData.strategy -}}
|
||||
{{- $strategy := $objectData.strategy -}}
|
||||
|
||||
{{- if not (mustHas $strategy (list "OnDelete" "RollingUpdate")) -}}
|
||||
{{- fail (printf "DaemonSet - Expected <strategy> to be one of [OnDelete, RollingUpdate], but got [%v]" $strategy) -}}
|
||||
{{- $strategies := (list "OnDelete" "RollingUpdate") -}}
|
||||
{{- if not (mustHas $strategy $strategies) -}}
|
||||
{{- fail (printf "DaemonSet - Expected <strategy> to be one of [%s], but got [%v]" (join ", " $strategies) $strategy) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
@@ -12,8 +12,9 @@ objectData:
|
||||
{{- if $objectData.strategy -}}
|
||||
{{- $strategy := $objectData.strategy -}}
|
||||
|
||||
{{- if not (mustHas $strategy (list "Recreate" "RollingUpdate")) -}}
|
||||
{{- fail (printf "Deployment - Expected <strategy> to be one of [Recreate, RollingUpdate], but got [%v]" $strategy) -}}
|
||||
{{- $strategies := (list "Recreate" "RollingUpdate") -}}
|
||||
{{- if not (mustHas $strategy $strategies) -}}
|
||||
{{- fail (printf "Deployment - Expected <strategy> to be one of [%s], but got [%v]" (join ", " $strategies) $strategy) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
@@ -12,8 +12,9 @@ objectData:
|
||||
{{- if $objectData.strategy -}}
|
||||
{{- $strategy := $objectData.strategy -}}
|
||||
|
||||
{{- if not (mustHas $strategy (list "OnDelete" "RollingUpdate")) -}}
|
||||
{{- fail (printf "StatefulSet - Expected <strategy> to be one of [OnDelete, RollingUpdate], but got [%v]" $strategy) -}}
|
||||
{{- $strategies := (list "OnDelete" "RollingUpdate") -}}
|
||||
{{- if not (mustHas $strategy $strategies) -}}
|
||||
{{- fail (printf "StatefulSet - Expected <strategy> to be one of [%s], but got [%v]" (join ", " $strategies) $strategy) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
{{/* Go over workload */}}
|
||||
{{- range $name, $workload := .Values.workload -}}
|
||||
|
||||
{{- if not (mustHas $workload.type (list "Deployment" "StatefulSet" "DaemonSet" "Job" "CronJob")) -}}
|
||||
{{- fail (printf "Workload - Expected <type> to be one of [Deployment, StatefulSet, DaemonSet, Job, CronJob], but got [%s]" $workload.type) -}}
|
||||
{{- $types := (list "Deployment" "StatefulSet" "DaemonSet" "Job" "CronJob") -}}
|
||||
{{- if not (mustHas $workload.type $types) -}}
|
||||
{{- fail (printf "Workload - Expected <type> to be one of [%s], but got [%s]" (join ", " $types) $workload.type) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* If workload is enabled */}}
|
||||
|
||||
Reference in New Issue
Block a user