Skip to content

Commit

Permalink
Add security context to init containers -- Added unit test for it (#76)
Browse files Browse the repository at this point in the history
* Add security context to init containers -- Added unit test for it

* Minor cleaning

---------

Co-authored-by: Laszlo Fogas <[email protected]>
  • Loading branch information
YoucefGuichi and laszlocph authored Aug 14, 2023
1 parent 7b56a9d commit d0aa57c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion charts/onechart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ spec:
- mountPath: {{ .path }}
name: {{ .name }}
{{- end }}
{{- end }}
{{- end }}
{{if .securityContext }}
securityContext:
{{- toYaml .securityContext | nindent 12 }}
{{- end}}
{{- end }}
containers:
- name: {{ template "robustName" .Release.Name }}
Expand Down
13 changes: 10 additions & 3 deletions charts/onechart/tests/deployment_initcontainers_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ tests:
- equal:
path: spec.template.spec.initContainers[0].command
value: ['/bin/sh', '-c', 'while true; do date; sleep 2; done && ls /data && printf something']




- it: Should set security context
set:
initContainers:
- securityContext:
runAsNonRoot: true
asserts:
- equal:
path: spec.template.spec.initContainers[0].securityContext.runAsNonRoot
value: true

0 comments on commit d0aa57c

Please sign in to comment.