Skip to content

Commit

Permalink
Adds helm test to reject a helm install with apiGateway.enabled=true
Browse files Browse the repository at this point in the history
  • Loading branch information
missylbytes committed Mar 13, 2024
1 parent 7c0506d commit c2efc8f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions charts/consul/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -682,4 +682,17 @@ Usage: {{ template "consul.versionInfo" }}
{{- $sanitizedVersion = $versionInfo }}
{{- end -}}
{{- printf "%s" $sanitizedVersion | quote }}
{{- end -}}
{{/*
Validate that the depraced stanze for .Values.apiGateway is not set.
Cleanup server.extraConfig entries to avoid conflicting entries:
- server.enableAgentDebug:
- `enable_debug` should not exist in extraConfig
Usage: {{ template "consul.validateExtraConfig" . }}
*/}}
{{- define "consul.validate_deprecated_apigateway_not_set" -}}
{{- if .Values.apiGateway}}
{{fail "[DEPRECATED and REMOVED] .Values.apiGateway is no longer supported as of Consul 1.19.0. Use connectInject.apiGateway instead."}}
{{- end -}}
{{- end -}}
1 change: 1 addition & 0 deletions charts/consul/templates/gateway-resources-job.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{ template "consul.validate_deprecated_apigateway_not_set" . }}
{{- if .Values.connectInject.enabled }}
apiVersion: batch/v1
kind: Job
Expand Down
9 changes: 9 additions & 0 deletions charts/consul/test/unit/helpers.bats
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,12 @@ load _helpers
[ "$status" -eq 1 ]
[[ "$output" =~ "When the value global.experiments.resourceAPIs is set, terminatingGateways.enabled is currently unsupported." ]]
}

@test "helper/consul.validate_deprecated_apiGateway_not_set: fails if .values.apiGateway is set" {
cd `chart_dir`
run helm template \
-s templates/tests/test-runner.yaml \
--set 'apiGateway.enabled=true' .
[ "$status" -eq 1 ]
[[ "$output" =~ "[DEPRECATED and REMOVED] .Values.apiGateway is no longer supported as of Consul 1.19.0. Use connectInject.apiGateway instead." ]]
}

0 comments on commit c2efc8f

Please sign in to comment.