From 2072bf2dcd0babe260654932f40a4d5fa13569df Mon Sep 17 00:00:00 2001 From: Theron Voran Date: Tue, 21 Apr 2020 08:19:17 -0700 Subject: [PATCH] Fix ha standby and active service annotations (#268) * service: fix annotations for HA standby/active services * added unit tests Co-authored-by: yotsub <63680950+yotsub@users.noreply.github.com> --- templates/server-ha-active-service.yaml | 2 +- templates/server-ha-standby-service.yaml | 2 +- test/unit/server-ha-active-service.bats | 14 ++++++++++++++ test/unit/server-ha-standby-service.bats | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/unit/server-ha-active-service.bats create mode 100644 test/unit/server-ha-standby-service.bats diff --git a/templates/server-ha-active-service.yaml b/templates/server-ha-active-service.yaml index 1af8520..0333df1 100644 --- a/templates/server-ha-active-service.yaml +++ b/templates/server-ha-active-service.yaml @@ -14,7 +14,7 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} annotations: {{- if .Values.server.service.annotations }} -{{ toYaml .Values.server.service.annotations | indent 4 }} +{{ tpl .Values.server.service.annotations . | indent 4 }} {{- end }} spec: type: ClusterIP diff --git a/templates/server-ha-standby-service.yaml b/templates/server-ha-standby-service.yaml index 2dd7522..d8df9e7 100644 --- a/templates/server-ha-standby-service.yaml +++ b/templates/server-ha-standby-service.yaml @@ -14,7 +14,7 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} annotations: {{- if .Values.server.service.annotations }} -{{ toYaml .Values.server.service.annotations | indent 4 }} +{{ tpl .Values.server.service.annotations . | indent 4 }} {{- end }} spec: type: ClusterIP diff --git a/test/unit/server-ha-active-service.bats b/test/unit/server-ha-active-service.bats new file mode 100644 index 0000000..4e6ad1a --- /dev/null +++ b/test/unit/server-ha-active-service.bats @@ -0,0 +1,14 @@ +#!/usr/bin/env bats + +load _helpers + +@test "server/ha-active-Service: generic annotations" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/server-ha-active-service.yaml \ + --set 'server.ha.enabled=true' \ + --set 'server.service.annotations=vaultIsAwesome: true' \ + . | tee /dev/stderr | + yq -r '.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr) + [ "${actual}" = "true" ] +} diff --git a/test/unit/server-ha-standby-service.bats b/test/unit/server-ha-standby-service.bats new file mode 100644 index 0000000..7630ac5 --- /dev/null +++ b/test/unit/server-ha-standby-service.bats @@ -0,0 +1,14 @@ +#!/usr/bin/env bats + +load _helpers + +@test "server/ha-standby-Service: generic annotations" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/server-ha-standby-service.yaml \ + --set 'server.ha.enabled=true' \ + --set 'server.service.annotations=vaultIsAwesome: true' \ + . | tee /dev/stderr | + yq -r '.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr) + [ "${actual}" = "true" ] +}