diff --git a/templates/server-service.yaml b/templates/server-service.yaml index 6dd2602..8fbe8c7 100644 --- a/templates/server-service.yaml +++ b/templates/server-service.yaml @@ -19,6 +19,9 @@ metadata: {{ toYaml .Values.server.service.annotations | indent 4 }} {{- end }} spec: + {{- if .Values.server.service.type}} + type: {{ .Values.server.service.type }} + {{- end}} {{- if .Values.server.service.clusterIP }} clusterIP: {{ .Values.server.service.clusterIP }} {{- end }} diff --git a/test/unit/server-service.bats b/test/unit/server-service.bats index 4c6c1aa..b5e7536 100755 --- a/test/unit/server-service.bats +++ b/test/unit/server-service.bats @@ -174,6 +174,55 @@ load _helpers [ "${actual}" = "true" ] } +@test "server/Service: type empty by default" { + cd `chart_dir` + local actual=$(helm template \ + -x templates/server-service.yaml \ + --set 'server.dev.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.type' | tee /dev/stderr) + [ "${actual}" = "null" ] + + local actual=$(helm template \ + -x templates/server-service.yaml \ + --set 'server.ha.enabled=true' \ + . | tee /dev/stderr | + yq -r '.spec.type' | tee /dev/stderr) + [ "${actual}" = "null" ] + + local actual=$(helm template \ + -x templates/server-service.yaml \ + . | tee /dev/stderr | + yq -r '.spec.type' | tee /dev/stderr) + [ "${actual}" = "null" ] +} + +@test "server/Service: type can set" { + cd `chart_dir` + local actual=$(helm template \ + -x templates/server-service.yaml \ + --set 'server.dev.enabled=true' \ + --set 'server.service.type=NodePort' \ + . | tee /dev/stderr | + yq -r '.spec.type' | tee /dev/stderr) + [ "${actual}" = "NodePort" ] + + local actual=$(helm template \ + -x templates/server-service.yaml \ + --set 'server.ha.enabled=true' \ + --set 'server.service.type=NodePort' \ + . | tee /dev/stderr | + yq -r '.spec.type' | tee /dev/stderr) + [ "${actual}" = "NodePort" ] + + local actual=$(helm template \ + -x templates/server-service.yaml \ + --set 'server.service.type=NodePort' \ + . | tee /dev/stderr | + yq -r '.spec.type' | tee /dev/stderr) + [ "${actual}" = "NodePort" ] +} + @test "server/Service: clusterIP empty by default" { cd `chart_dir` local actual=$(helm template \