Skip to content

Commit

Permalink
Remove combination of enabling ingress.
Browse files Browse the repository at this point in the history
  • Loading branch information
zinref authored and thisisnotashwin committed Jan 22, 2021
1 parent 6c22edb commit 63730cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 48 deletions.
16 changes: 11 additions & 5 deletions templates/ui-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if (and (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled)) (or (and (ne (.Values.ui.enabled | toString) "-") .Values.ui.enabled) (and (eq (.Values.ui.enabled | toString) "-") .Values.global.enabled)) (or (and (ne (.Values.ui.ingress.enabled | toString) "-") .Values.ui.ingress.enabled) (and (eq (.Values.ui.ingress.enabled | toString) "-") .Values.global.enabled))) }}
{{- if (and (ne (.Values.ui.ingress.enabled | toString) "-") .Values.ui.ingress.enabled) }}
{{- $serviceName := printf "%s-%s" (include "consul.fullname" .) "ui" -}}
apiVersion: extensions/v1beta1
kind: Ingress
Expand All @@ -12,20 +12,26 @@ metadata:
release: {{ .Release.Name }}
{{- if .Values.ui.ingress.annotations }}
annotations:
{{ tpl (toYaml .Values.ui.ingress.annotations) . | nindent 4 | trim }}
{{ tpl .Values.ui.ingress.annotations . | nindent 4 | trim }}
{{- end}}
spec:
rules:
{{- range .Values.ui.ingress.hosts }}
{{- range .Values.ui.ingress.hosts }}
- host: {{ . }}
http:
paths:
- backend:
serviceName: {{ $serviceName }}
servicePort: 80
{{- end -}}
{{- end -}}
{{- if .Values.ui.ingress.tls }}
tls:
{{ tpl (toYaml .Values.ui.ingress.tls) . | nindent 4 | trim }}
{{- range $value := .Values.ui.ingress.tls }}
- hosts:
{{- range $value.hosts }}
- {{ . }}
{{- end }}
secretName: {{ $value.secretName }}
{{- end }}
{{- end }}
{{- end }}
48 changes: 5 additions & 43 deletions test/unit/ui-ingress.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,16 @@ load _helpers
[ "${actual}" = "false" ]
}

@test "ui/Ingress: enable with global.enabled false" {
@test "ui/Ingress: enable with ui.ingress.enabled" {
cd `chart_dir`
local actual=$(helm template \
-x templates/ui-ingress.yaml \
--set 'global.enabled=false' \
--set 'server.enabled=true' \
--set 'ui.enabled=true' \
--set 'ui.ingress.enabled=true' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "ui/Ingress: disable with server.enabled" {
cd `chart_dir`
local actual=$(helm template \
-x templates/ui-ingress.yaml \
--set 'server.enabled=false' \
--set 'ui.ingress.enabled=true' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

@test "ui/Ingress: disable with ui.enabled" {
cd `chart_dir`
local actual=$(helm template \
-x templates/ui-ingress.yaml \
--set 'ui.enabled=false' \
--set 'ui.ingress.enabled=true' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

@test "ui/Ingress: disable with ui.ingress.enabled" {
cd `chart_dir`
local actual=$(helm template \
Expand All @@ -56,24 +31,11 @@ load _helpers
[ "${actual}" = "false" ]
}

@test "ui/Ingress: disable with global.enabled" {
@test "ui/Ingress: disable with ui.ingress.enabled dash string" {
cd `chart_dir`
local actual=$(helm template \
-x templates/ui-ingress.yaml \
--set 'global.enabled=false' \
--set 'ui.ingress.enabled=true' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

@test "ui/Ingress: disable with global.enabled and server.enabled on" {
cd `chart_dir`
local actual=$(helm template \
-x templates/ui-service.yaml \
--set 'global.enabled=false' \
--set 'server.enabled=true' \
--set 'ui.ingress.enabled=true' \
--set 'ui.ingress.enabled=-' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
Expand Down Expand Up @@ -132,7 +94,7 @@ load _helpers
local actual=$(helm template \
-x templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'ui.ingress.tls[0].hosts[0]=foo.com' \
--set 'ui.ingress.tls[0].hosts[0]=sslexample.foo.com' \
--set 'ui.ingress.tls[0].secretName=testsecret-tls' \
. | tee /dev/stderr |
yq -r '.spec.tls[0].secretName' | tee /dev/stderr)
Expand All @@ -157,7 +119,7 @@ load _helpers
local actual=$(helm template \
-x templates/ui-ingress.yaml \
--set 'ui.ingress.enabled=true' \
--set 'ui.ingress.annotations.foo=bar' \
--set 'ui.ingress.annotations=foo: bar' \
. | tee /dev/stderr |
yq -r '.metadata.annotations.foo' | tee /dev/stderr)
[ "${actual}" = "bar" ]
Expand Down

0 comments on commit 63730cb

Please sign in to comment.