From 57571e766ede470d7f5279346859deb1239b4845 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Wed, 9 Nov 2022 21:09:22 -0500 Subject: [PATCH] Add CONSUL_TLS_SERVER_NAME --- .../api-gateway-controller-deployment.yaml | 6 ++++++ .../api-gateway-controller-deployment.bats | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/charts/consul/templates/api-gateway-controller-deployment.yaml b/charts/consul/templates/api-gateway-controller-deployment.yaml index 7a4754c552..6968465306 100644 --- a/charts/consul/templates/api-gateway-controller-deployment.yaml +++ b/charts/consul/templates/api-gateway-controller-deployment.yaml @@ -82,6 +82,12 @@ spec: value: {{ template "consul.fullname" . }}-server:8500 {{- end }} {{- end }} + - name: CONSUL_HTTP_SSL + value: {{ .Values.global.tls.enabled }} + {{- if and .Values.externalServers.enabled .Values.externalServers.tlsServerName }} + - name: CONSUL_TLS_SERVER_NAME + value: {{ .Values.externalServers.tlsServerName }} + {{- end }} command: - "/bin/sh" - "-ec" diff --git a/charts/consul/test/unit/api-gateway-controller-deployment.bats b/charts/consul/test/unit/api-gateway-controller-deployment.bats index 4a56a891d4..5b3ee062b4 100755 --- a/charts/consul/test/unit/api-gateway-controller-deployment.bats +++ b/charts/consul/test/unit/api-gateway-controller-deployment.bats @@ -1191,3 +1191,22 @@ load _helpers [ "${actual}" = "true" ] } +#-------------------------------------------------------------------- +# externalServers tlsServerName + +@test "apiGateway/Deployment: CONSUL_TLS_SERVER_NAME can be set for externalServers" { + cd `chart_dir` + local actual=$(helm template \ + -s templates/api-gateway-controller-deployment.yaml \ + --set 'apiGateway.enabled=true' \ + --set 'apiGateway.image=bar' \ + --set 'global.tls.enabled=true' \ + --set 'externalServers.enabled=true' \ + --set 'externalServers.hosts[0]=external-consul.host' \ + --set 'externalServers.httpsPort=8501' \ + --set 'externalServers.tlsServerName=hashi' \ + --set 'server.enabled=false' \ + . | tee /dev/stderr | + yq '.spec.template.spec.containers[0].env[4].value == "hashi"' | tee /dev/stderr) + [ "${actual}" = "true" ] +}