From 1c0b30e6d8e61e1f8e8891e220715e357f67cc07 Mon Sep 17 00:00:00 2001 From: Luke Kysow <1034429+lkysow@users.noreply.github.com> Date: Fri, 22 Jan 2021 10:50:17 -0800 Subject: [PATCH] Don't fail centralConfig.enabled=true --- CHANGELOG.md | 2 +- templates/connect-inject-deployment.yaml | 2 +- test/unit/connect-inject-deployment.bats | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db64b476e..57ff0a1c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ IMPROVEMENTS: Consul servers have to be restarted in order for them to update their server certificates [[GH-749](https://github.com/hashicorp/consul-helm/pull/721)] BREAKING CHANGES: -* The follow Helm settings are no longer supported and will cause errors on `helm upgrade`. +* The following Helm settings are no longer supported and will cause errors on `helm upgrade`. See [Upgrade to CRDs](https://www.consul.io/docs/k8s/crds/upgrade-to-crds) for more information on how to upgrade. [[GH-763](https://github.com/hashicorp/consul-helm/pull/763)] * `connectInject.centralConfig.defaultProtocol` diff --git a/templates/connect-inject-deployment.yaml b/templates/connect-inject-deployment.yaml index 96a9e9578..ab930718e 100644 --- a/templates/connect-inject-deployment.yaml +++ b/templates/connect-inject-deployment.yaml @@ -4,7 +4,7 @@ {{- if and .Values.connectInject.consulNamespaces.mirroringK8S (not .Values.global.enableConsulNamespaces) }}{{ fail "global.enableConsulNamespaces must be true if mirroringK8S=true" }}{{ end }} {{- if .Values.connectInject.centralConfig }}{{- if eq (toString .Values.connectInject.centralConfig.enabled) "false" }}{{ fail "connectInject.centralConfig.enabled cannot be set to false; to disable, set enable_central_service_config to false in server.extraConfig and client.extraConfig" }}{{ end -}}{{ end -}} {{- if .Values.connectInject.centralConfig }}{{- if .Values.connectInject.centralConfig.defaultProtocol }}{{ fail "connectInject.centralConfig.defaultProtocol is no longer supported; instead you must migrate to CRDs (see www.consul.io/docs/k8s/crds/upgrade-to-crds)" }}{{ end }}{{ end -}} -{{- if .Values.connectInject.centralConfig }}{{- if ne (trim .Values.connectInject.centralConfig.proxyDefaults) `{}` }}{{ fail "connectInject.centralConfig.proxyDefaults is no longer supported; instead you must migrate to CRDs (see www.consul.io/docs/k8s/crds/upgrade-to-crds)" }}{{ end }}{{ end -}} +{{- if .Values.connectInject.centralConfig }}{{ if .Values.connectInject.centralConfig.proxyDefaults }}{{- if ne (trim .Values.connectInject.centralConfig.proxyDefaults) `{}` }}{{ fail "connectInject.centralConfig.proxyDefaults is no longer supported; instead you must migrate to CRDs (see www.consul.io/docs/k8s/crds/upgrade-to-crds)" }}{{ end }}{{ end }}{{ end -}} {{- if .Values.connectInject.imageEnvoy }}{{ fail "connectInject.imageEnvoy must be specified in global.imageEnvoy" }}{{ end }} # The deployment for running the Connect sidecar injector apiVersion: apps/v1 diff --git a/test/unit/connect-inject-deployment.bats b/test/unit/connect-inject-deployment.bats index e7b40cae2..92e7d7604 100755 --- a/test/unit/connect-inject-deployment.bats +++ b/test/unit/connect-inject-deployment.bats @@ -113,6 +113,17 @@ load _helpers [[ "$output" =~ "connectInject.centralConfig.proxyDefaults is no longer supported; instead you must migrate to CRDs (see www.consul.io/docs/k8s/crds/upgrade-to-crds)" ]] } +@test "connectInject/Deployment: does not fail if connectInject.centralConfig.enabled is set to true" { + cd `chart_dir` + local actual=$(helm template \ + -s templates/connect-inject-deployment.yaml \ + --set 'connectInject.enabled=true' \ + --set 'connectInject.centralConfig.enabled=true' \ + . | tee /dev/stderr | + yq 'length > 0' | tee /dev/stderr) + [ "${actual}" = "true" ] +} + @test "connectInject/Deployment: does not fail if connectInject.centralConfig.proxyDefaults is set to {}" { cd `chart_dir`