From 14d1f97edda10c314849f8f073980a1156229226 Mon Sep 17 00:00:00 2001 From: Calvin Leung Huang <1883212+calvn@users.noreply.github.com> Date: Tue, 6 Jul 2021 09:49:48 -0700 Subject: [PATCH] injector: add templateConfig.exitOnRetryFailure annotation (#560) * injector: add templateConfig.exitOnRetryFailure annotation * update values.schema.json --- templates/injector-deployment.yaml | 2 ++ test/unit/injector-deployment.bats | 25 +++++++++++++++++++++++++ values.schema.json | 8 ++++++++ values.yaml | 4 ++++ 4 files changed, 39 insertions(+) diff --git a/templates/injector-deployment.yaml b/templates/injector-deployment.yaml index 4756a25..c063a87 100644 --- a/templates/injector-deployment.yaml +++ b/templates/injector-deployment.yaml @@ -107,6 +107,8 @@ spec: value: "{{ .Values.injector.agentDefaults.memLimit }}" - name: AGENT_INJECT_DEFAULT_TEMPLATE value: "{{ .Values.injector.agentDefaults.template }}" + - name: AGENT_INJECT_TEMPLATE_CONFIG_EXIT_ON_RETRY_FAILURE + value: "{{ .Values.injector.agentDefaults.templateConfig.exitOnRetryFailure }}" {{- include "vault.extraEnvironmentVars" .Values.injector | nindent 12 }} args: - agent-inject diff --git a/test/unit/injector-deployment.bats b/test/unit/injector-deployment.bats index cd6f1dd..edd5a00 100755 --- a/test/unit/injector-deployment.bats +++ b/test/unit/injector-deployment.bats @@ -640,3 +640,28 @@ load _helpers yq -r 'map(select(.name=="AGENT_INJECT_DEFAULT_TEMPLATE")) | .[] .value' | tee /dev/stderr) [ "${value}" = "json" ] } + +@test "injector/deployment: agent default template_config.exit_on_retry_failure" { + cd `chart_dir` + local object=$(helm template \ + --show-only templates/injector-deployment.yaml \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.containers[0].env' | tee /dev/stderr) + + local value=$(echo $object | + yq -r 'map(select(.name=="AGENT_INJECT_TEMPLATE_CONFIG_EXIT_ON_RETRY_FAILURE")) | .[] .value' | tee /dev/stderr) + [ "${value}" = "true" ] +} + +@test "injector/deployment: can set agent template_config.exit_on_retry_failure" { + cd `chart_dir` + local object=$(helm template \ + --show-only templates/injector-deployment.yaml \ + --set='injector.agentDefaults.templateConfig.exitOnRetryFailure=false' \ + . | tee /dev/stderr | + yq -r '.spec.template.spec.containers[0].env' | tee /dev/stderr) + + local value=$(echo $object | + yq -r 'map(select(.name=="AGENT_INJECT_TEMPLATE_CONFIG_EXIT_ON_RETRY_FAILURE")) | .[] .value' | tee /dev/stderr) + [ "${value}" = "false" ] +} \ No newline at end of file diff --git a/values.schema.json b/values.schema.json index db3b806..e8b3d2c 100644 --- a/values.schema.json +++ b/values.schema.json @@ -186,6 +186,14 @@ }, "template": { "type": "string" + }, + "templateConfig": { + "type": "object", + "properties": { + "exitOnRetryFailure": { + "type": "boolean" + } + } } } }, diff --git a/values.yaml b/values.yaml index 4516e87..2271f30 100644 --- a/values.yaml +++ b/values.yaml @@ -75,6 +75,10 @@ injector: # Possible values include: "json" and "map". template: "map" + # Default values within Agent's template_config stanza. + templateConfig: + exitOnRetryFailure: true + # Mount Path of the Vault Kubernetes Auth Method. authPath: "auth/kubernetes"