Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Kyle Schochenmaier <[email protected]>
  • Loading branch information
tekicat and kschoche authored Sep 26, 2023
1 parent 663a24e commit beaea6c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
4 changes: 2 additions & 2 deletions templates/server-ha-active-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
vault-active: "true"
annotations:
{{ template "vault.service.active.annotations" .}}
{{ template "vault.service.annotations" .}}
{{- template "vault.service.active.annotations" . }}
{{- template "vault.service.annotations" . }}
spec:
{{- if .Values.server.service.type}}
type: {{ .Values.server.service.type }}
Expand Down
4 changes: 2 additions & 2 deletions templates/server-ha-standby-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
annotations:
{{ template "vault.service.standby.annotations" .}}
{{ template "vault.service.annotations" .}}
{{- template "vault.service.standby.annotations" . }}
{{- template "vault.service.annotations" . }}
spec:
{{- if .Values.server.service.type}}
type: {{ .Values.server.service.type }}
Expand Down
14 changes: 14 additions & 0 deletions test/unit/server-ha-active-service.bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,21 @@ load _helpers
yq -r '.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "server/ha-active-Service: with both annotations set" {
cd `chart_dir`
local object=$(helm template \
--show-only templates/server-ha-active-service.yaml \
--set 'server.ha.enabled=true' \
--set 'server.service.active.annotations=vaultIsAwesome: true' \
--set 'server.service.annotations=vaultIsNotAwesome: false' \
. | tee /dev/stderr |
yq -r '.metadata' | tee /dev/stderr)

local actual=$(echo "$object" | yq '.annotations["vaultIsAwesome"]' | tee /dev/stderr)
[ "${actual}" = "true" ]
actual=$(echo "$object" | yq '.annotations["vaultIsNotAwesome"]' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "server/ha-active-Service: disable with ha.enabled false" {
cd `chart_dir`
local actual=$( (helm template \
Expand Down
14 changes: 14 additions & 0 deletions test/unit/server-ha-standby-service.bats
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,21 @@ load _helpers
yq -r '.metadata.annotations["vaultIsAwesome"]' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "server/ha-standby-Service: with both annotations set" {
cd `chart_dir`
local object=$(helm template \
--show-only templates/server-ha-standby-service.yaml \
--set 'server.ha.enabled=true' \
--set 'server.service.standby.annotations=vaultIsAwesome: true' \
--set 'server.service.annotations=vaultIsNotAwesome: false' \
. | tee /dev/stderr |
yq -r '.metadata' | tee /dev/stderr)

local actual=$(echo "$object" | yq '.annotations["vaultIsAwesome"]' | tee /dev/stderr)
[ "${actual}" = "true" ]
actual=$(echo "$object" | yq '.annotations["vaultIsNotAwesome"]' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "server/ha-standby-Service: disable with ha.enabled false" {
cd `chart_dir`
local actual=$( (helm template \
Expand Down
18 changes: 8 additions & 10 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -658,22 +658,20 @@ server:
service:
enabled: true
# Enable or disable the vault-active service, which selects Vault pods that
# have labelled themselves as the cluster leader with `vault-active: "true"`.
# Also helps in to add extra annotations for the service definition.
# have labeled themselves as the cluster leader with `vault-active: "true"`.
active:
enabled: true
# Extra annotations for the service definition. This can either be YAML or a
# YAML-formatted multi-line templated string map of the annotations to apply
# to the service.
# Extra annotations for the service definition. This can either be YAML or a
# YAML-formatted multi-line templated string map of the annotations to apply
# to the active service.
annotations: {}
# Enable or disable the vault-standby service, which selects Vault pods that
# have labelled themselves as a cluster follower with `vault-active: "false"`.
# Also helps in to add extra annotations for the service definition.
# have labeled themselves as a cluster follower with `vault-active: "false"`.
standby:
enabled: true
# Extra annotations for the service definition. This can either be YAML or a
# YAML-formatted multi-line templated string map of the annotations to apply
# to the service.
# Extra annotations for the service definition. This can either be YAML or a
# YAML-formatted multi-line templated string map of the annotations to apply
# to the standby service.
annotations: {}
# If enabled, the service selectors will include `app.kubernetes.io/instance: {{ .Release.Name }}`
# When disabled, services may select Vault pods not deployed from the chart.
Expand Down

0 comments on commit beaea6c

Please sign in to comment.