Skip to content

Commit

Permalink
fix: correct pod security context block indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyowenpowell committed Oct 22, 2024
1 parent 12d4b46 commit 8848ba8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
26 changes: 13 additions & 13 deletions snyk-monitor/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.podSecurityContext }}
securityContext:
{{- $fsGroupOverride := dict }}
{{- if hasKey $.Values.securityContext "fsGroup" }}
{{- $fsGroupOverride = dict "fsGroup" (int $.Values.securityContext.fsGroup) }}
{{- end }}
{{- merge $fsGroupOverride . | toYaml | nindent 8 }}
{{- else }}
{{- if .Values.securityContext.fsGroup }}
securityContext:
fsGroup: {{ int .Values.securityContext.fsGroup }}
{{- end }}
{{- end }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- $fsGroupOverride := dict }}
{{- if hasKey $.Values.securityContext "fsGroup" }}
{{- $fsGroupOverride = dict "fsGroup" (int $.Values.securityContext.fsGroup) }}
{{- end }}
{{- merge $fsGroupOverride . | toYaml | nindent 8 }}
{{- else }}
{{- if .Values.securityContext.fsGroup }}
securityContext:
fsGroup: {{ int .Values.securityContext.fsGroup }}
{{- end }}
{{- end }}
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
Expand Down
9 changes: 9 additions & 0 deletions test/integration/kubernetes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,15 @@ test('snyk-monitor secure configuration is as expected', async () => {
namespace,
);
const deployment = response.body;
expect(deployment.spec?.template.spec).toEqual(
expect.objectContaining({
securityContext: {
fsGroup: 65534,
fsGroupChangePolicy: 'Always',
},
}),
);

expect(deployment.spec?.template?.spec?.containers?.[0]).toEqual(
expect.objectContaining({
securityContext: {
Expand Down
1 change: 1 addition & 0 deletions test/setup/deployers/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async function deployKubernetesMonitor(
'--set rbac.serviceAccount.annotations."foo"="bar" ' +
'--set volumes.projected.serviceAccountToken=true ' +
'--set securityContext.fsGroup=65534 ' +
'--set podSecurityContext.fsGroupChangePolicy="Always" ' +
'--set skopeo.compression.level=1 ' +
'--set workers.count=5 ' +
'--set sysdig.enabled=true ',
Expand Down

0 comments on commit 8848ba8

Please sign in to comment.