test/unit: connect inject Deployment
This commit is contained in:
parent
489a396b4c
commit
fc6d86b96d
3 changed files with 90 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
# The deployment for running the Connect sidecar injector
|
||||
{{- if (default .Values.connectInject.enabled .Values.global.enabled) }}
|
||||
{{- if (or (and (ne (.Values.connectInject.enabled | toString) "-") .Values.connectInject.enabled) (and (eq (.Values.connectInject.enabled | toString) "-") .Values.global.enabled)) }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
|
|
88
test/unit/connect-inject-deployment.bats
Executable file
88
test/unit/connect-inject-deployment.bats
Executable file
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load _helpers
|
||||
|
||||
@test "connectInject/Deployment: enabled by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Deployment: enable with global.enabled false" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
--set 'connectInject.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Deployment: disable with connectInject.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Deployment: disable with global.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Deployment: no secretName: no tls-{cert,key}-file set" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-cert-file"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-key-file"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-auto"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Deployment: with secretName: tls-{cert,key}-file set" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.certs.secretName=foo' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-cert-file"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.certs.secretName=foo' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-key-file"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.certs.secretName=foo' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-auto"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
|
@ -66,7 +66,7 @@ client:
|
|||
|
||||
# ConnectInject will enable the automatic Connect sidecar injector.
|
||||
connectInject:
|
||||
enabled: null
|
||||
enabled: "-"
|
||||
image: "us.gcr.io/mitchellh-k8s/consul-k8s:latest"
|
||||
default: false # true will inject by default, otherwise requires annotation
|
||||
caBundle: "" # empty will auto generate the bundle
|
||||
|
|
Loading…
Reference in a new issue