Skip to content

Commit

Permalink
Add tolerations and nodeSelector to server-acl-init template with BATS
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Eckert committed Oct 3, 2022
1 parent 00d9349 commit b609ab5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
8 changes: 8 additions & 0 deletions charts/consul/templates/server-acl-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ spec:
limits:
memory: "50Mi"
cpu: "50m"
{{- if .Values.global.acls.job.tolerations }}
tolerations:
{{ tpl .Values.global.acls.job.tolerations . | indent 12 | trim }}
{{- end }}
{{- if .Values.global.acls.job.nodeSelector }}
nodeSelector:
{{ tpl .Values.global.acls.job.nodeSelector . | indent 12 | trim }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
45 changes: 45 additions & 0 deletions charts/consul/test/unit/server-acl-init-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,51 @@ load _helpers
[ "${actual}" = "true" ]
}

#--------------------------------------------------------------------
# global.acls.job

@test "serverACLInit/Job: tolerations not set by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].tolerations' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "serverACLInit/Job: tolerations can be set" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.acls.job.tolerations=- key: value' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].tolerations[0].key' | tee /dev/stderr)
[ "${actual}" = "value" ]
}

@test "serverACLInit/Job: nodeSelector not set by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].nodeSelector' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "serverACLInit/Job: nodeSelector can be set" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.acls.job.nodeSelector=- key: value' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].nodeSelector[0].key' | tee /dev/stderr)
[ "${actual}" = "value" ]
}

#--------------------------------------------------------------------
# externalServers.enabled

Expand Down

0 comments on commit b609ab5

Please sign in to comment.