Add security context to init containers -- Added unit test for it (#76)
* Add security context to init containers -- Added unit test for it * Minor cleaning --------- Co-authored-by: Laszlo Fogas <laszlo@gimlet.io>
This commit is contained in:
@@ -67,7 +67,11 @@ spec:
|
|||||||
- mountPath: {{ .path }}
|
- mountPath: {{ .path }}
|
||||||
name: {{ .name }}
|
name: {{ .name }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{if .securityContext }}
|
||||||
|
securityContext:
|
||||||
|
{{- toYaml .securityContext | nindent 12 }}
|
||||||
|
{{- end}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
containers:
|
containers:
|
||||||
- name: {{ template "robustName" .Release.Name }}
|
- name: {{ template "robustName" .Release.Name }}
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ tests:
|
|||||||
- equal:
|
- equal:
|
||||||
path: spec.template.spec.initContainers[0].command
|
path: spec.template.spec.initContainers[0].command
|
||||||
value: ['/bin/sh', '-c', 'while true; do date; sleep 2; done && ls /data && printf something']
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user