mirror of
https://github.com/truenas/charts.git
synced 2024-04-21 15:21:45 +00:00
externalname can have no ports
This commit is contained in:
@@ -39,6 +39,33 @@ tests:
|
||||
protocol: TCP
|
||||
targetPort: 12345
|
||||
|
||||
- it: should pass with type externalName, without ports
|
||||
set:
|
||||
service:
|
||||
my-service:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: ExternalName
|
||||
externalName: my-external-name
|
||||
asserts:
|
||||
- documentIndex: *serviceDoc
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *serviceDoc
|
||||
isAPIVersion:
|
||||
of: v1
|
||||
- documentIndex: *serviceDoc
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test
|
||||
- documentIndex: *serviceDoc
|
||||
equal:
|
||||
path: spec
|
||||
value:
|
||||
type: ExternalName
|
||||
externalName: my-external-name
|
||||
publishNotReadyAddresses: false
|
||||
|
||||
- it: should pass with type ExternalName and available options set
|
||||
set:
|
||||
some_ip: 172.16.20.35
|
||||
|
||||
@@ -83,9 +83,11 @@ spec:
|
||||
{{- include "ix.v1.common.lib.service.spec.externalName" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 2 -}}
|
||||
{{- else if eq $svcType "ExternalIP" -}}
|
||||
{{- include "ix.v1.common.lib.service.spec.externalIP" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 2 -}}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- with (include "ix.v1.common.lib.service.ports" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim) }}
|
||||
ports:
|
||||
{{- include "ix.v1.common.lib.service.ports" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 4 }}
|
||||
{{- . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- if not (mustHas $svcType $specialTypes) }}
|
||||
selector:
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $podValues.shortName) | trim | nindent 4 -}}
|
||||
|
||||
@@ -28,28 +28,30 @@ objectData:
|
||||
{{- end -}}
|
||||
|
||||
{{- $hasEnabledPort := false -}}
|
||||
{{- range $name, $port := $objectData.ports -}}
|
||||
{{- if $port.enabled -}}
|
||||
{{- $hasEnabledPort = true -}}
|
||||
{{- if ne $objectData.type "ExternalName" -}}
|
||||
{{- 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 and $port.protocol (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 -}}
|
||||
|
||||
{{- 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 and $port.protocol (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 -}}
|
||||
|
||||
{{- if not $hasEnabledPort -}}
|
||||
{{- fail "Service - Expected enabled service to have at least one port" -}}
|
||||
{{- if not $hasEnabledPort -}}
|
||||
{{- fail "Service - Expected enabled service to have at least one port" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user