From 5f2e1d470fc1f04972232f90c43883873bae0485 Mon Sep 17 00:00:00 2001 From: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com> Date: Wed, 14 Apr 2021 08:23:50 -0400 Subject: [PATCH] Fix injector unit test failing (#496) * Fix injector unit test failing * Add null check * Add default if unset for CI --- test/unit/injector-deployment.bats | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/unit/injector-deployment.bats b/test/unit/injector-deployment.bats index dbeb1d9..3b6efbc 100755 --- a/test/unit/injector-deployment.bats +++ b/test/unit/injector-deployment.bats @@ -159,9 +159,13 @@ load _helpers yq -r 'map(select(.name=="AGENT_INJECT_TLS_AUTO")) | .[] .value' | tee /dev/stderr) [ "${value}" = "RELEASE-NAME-vault-agent-injector-cfg" ] + # helm template does uses current context namespace and ignores namespace flags, so + # discover the targeted namespace so we can check the rendered value correctly. + local namespace=$(kubectl config view --minify --output 'jsonpath={..namespace}') + local value=$(echo $object | yq -r 'map(select(.name=="AGENT_INJECT_TLS_AUTO_HOSTS")) | .[] .value' | tee /dev/stderr) - [ "${value}" = "RELEASE-NAME-vault-agent-injector-svc,RELEASE-NAME-vault-agent-injector-svc.default,RELEASE-NAME-vault-agent-injector-svc.default.svc" ] + [ "${value}" = "RELEASE-NAME-vault-agent-injector-svc,RELEASE-NAME-vault-agent-injector-svc.${namespace:-default},RELEASE-NAME-vault-agent-injector-svc.${namespace:-default}.svc" ] } @test "injector/deployment: with externalVaultAddr" {