Skip to content

Commit

Permalink
feat: pass annotations to reconciliation jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
jack1902 authored and eshepelyuk committed Jan 18, 2022
1 parent 1f71ed6 commit 2eba6a4
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
5 changes: 5 additions & 0 deletions templates/cronjob-reconcile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ spec:
jobTemplate:
spec:
template:
metadata:
{{- with .Values.reconcile.annotations }}
annotations:
{{- toYaml . | nindent 12 }}
{{- end }}
spec:
restartPolicy: Never
volumes:
Expand Down
5 changes: 5 additions & 0 deletions templates/job-setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ metadata:
spec:
backoffLimit: 3
template:
metadata:
{{- with .Values.reconcile.annotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
restartPolicy: Never
volumes:
Expand Down
10 changes: 10 additions & 0 deletions test/linter/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,14 @@ if [ $? -eq 0 ]; then
exit 1
fi

helm lint . --strict --set 'reconcile.annotations=false'
if [ $? -eq 0 ]; then
exit 1
fi

helm lint . --strict --set 'reconcile.annotations={1,2,3}'
if [ $? -eq 0 ]; then
exit 1
fi


40 changes: 40 additions & 0 deletions test/unit/job-annotations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
suite: reconcile cronjob annotations
templates:
- cronjob-reconcile.yaml
- job-setup.yaml
tests:
- it: should populate job annotations
set:
reconcile:
annotations:
istest: yes
asserts:
- isNotNull:
path: spec.jobTemplate.spec.template.metadata.annotations.istest
template: cronjob-reconcile.yaml
- isNotNull:
path: spec.template.metadata.annotations.istest
template: job-setup.yaml
- isNotEmpty:
path: spec.jobTemplate.spec.template.metadata.annotations.istest
template: cronjob-reconcile.yaml
- isNotEmpty:
path: spec.template.metadata.annotations.istest
template: job-setup.yaml
- equal:
path: spec.jobTemplate.spec.template.metadata.annotations.istest
value: yes
template: cronjob-reconcile.yaml
- equal:
path: spec.template.metadata.annotations.istest
value: yes
template: job-setup.yaml

- it: should not have annotations by default
asserts:
- isNull:
path: spec.jobTemplate.spec.template.metadata
template: cronjob-reconcile.yaml
- isNull:
path: spec.template.metadata
template: job-setup.yaml
3 changes: 3 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
"failedJobsHistoryLimit": {
"type": ["null", "integer"], "default": null, "title": "number of failed jobs to keep"
},
"annotations": {
"type": "object", "title": "optional annotations to apply to the pods spun up via the job", "default": {}
},
"resources": { "$ref": "#/definitions/resources" }
}
},
Expand Down
1 change: 1 addition & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ reconcile:
overwriteZk: true
successfulJobsHistoryLimit: null
failedJobsHistoryLimit: null
annotations: {}
# reconcile resource configuration
# resources:
# limits:
Expand Down

0 comments on commit 2eba6a4

Please sign in to comment.