Skip to content

Commit

Permalink
Add tolerations and nodeSelector to server-acl-init-cleanup template …
Browse files Browse the repository at this point in the history
…with BATS
  • Loading branch information
Thomas Eckert committed Oct 3, 2022
1 parent b609ab5 commit 928772d
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-cleanup-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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-cleanup-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,48 @@ load _helpers
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

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

@test "serverACLInitCleanup/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 "serverACLInitCleanup/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" ]
}

0 comments on commit 928772d

Please sign in to comment.