Skip to content

Commit 04077a9

Browse files
authored
fix: inherit global security defaults (#31)
## Summary - seed pod/container security contexts with global defaults before applying chart-specific overrides - keep local chart values authoritative while falling back to global kit settings for empty maps - document refresh occurs via existing helm-docs automation ## Testing - bun run check - bun run typecheck - bun run test ## Summary by Sourcery Seed Helm chart pod and container security contexts with new global defaults while preserving chart-specific overrides, update default persistence setting, and refresh chart documentation. Enhancements: - Introduce global.securityContexts.pod and .container in network chart values for fallback security contexts - Merge global and local security context settings in bootstrapper, network-nodes, and validator templates - Enable persistent volumes by default for the network-nodes chart Documentation: - Add documentation for global.securityContexts in values.yaml and READMEs - Refresh chart documentation via helm-docs automation
1 parent dca00e8 commit 04077a9

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

charts/network/charts/network-bootstrapper/templates/_helpers.tpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,15 @@ Accepts either a YAML string or a list of init container maps and indents output
7777
{{- end -}}
7878
{{- end -}}
7979
{{- end -}}
80+
81+
{{/*
82+
Resolve pod and container security contexts by layering chart values over global defaults.
83+
*/}}
84+
{{- define "network-bootstrapper.securityContexts" -}}
85+
{{- $root := . -}}
86+
{{- $globalValues := ($root.Values.global | default (dict)) -}}
87+
{{- $globalSecurityContexts := dig "securityContexts" $globalValues (dict) -}}
88+
{{- $pod := mergeOverwrite (deepCopy (dig "pod" $globalSecurityContexts (dict))) (default (dict) $root.Values.podSecurityContext) -}}
89+
{{- $container := mergeOverwrite (deepCopy (dig "container" $globalSecurityContexts (dict))) (default (dict) $root.Values.securityContext) -}}
90+
{{- dict "pod" $pod "container" $container | toYaml -}}
91+
{{- end -}}

charts/network/charts/network-bootstrapper/templates/job.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ spec:
2727
{{- toYaml . | nindent 8 }}
2828
{{- end }}
2929
serviceAccountName: {{ include "network-bootstrapper.serviceAccountName" . }}
30-
{{- $globalValues := (.Values.global | default (dict)) }}
31-
{{- $globalSecurityContexts := dig "securityContexts" $globalValues (dict) }}
32-
{{- $podSecurityContext := merge (deepCopy (default (dict) .Values.podSecurityContext)) (dig "pod" $globalSecurityContexts (dict)) }}
33-
{{- $containerSecurityContext := merge (deepCopy (default (dict) .Values.securityContext)) (dig "container" $globalSecurityContexts (dict)) }}
30+
{{- $securityContexts := include "network-bootstrapper.securityContexts" . | fromYaml }}
31+
{{- $podSecurityContext := index $securityContexts "pod" }}
32+
{{- $containerSecurityContext := index $securityContexts "container" }}
3433
{{- if $podSecurityContext }}
3534
securityContext:
3635
{{- toYaml $podSecurityContext | nindent 8 }}

charts/network/charts/network-nodes/templates/_helpers.tpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,15 @@ Accepts either a YAML string or a list of init container maps and indents output
126126
{{- end -}}
127127
{{- end -}}
128128
{{- end -}}
129+
130+
{{/*
131+
Resolve pod and container security contexts using global defaults plus chart overrides.
132+
*/}}
133+
{{- define "nodes.securityContexts" -}}
134+
{{- $root := . -}}
135+
{{- $globalValues := ($root.Values.global | default (dict)) -}}
136+
{{- $globalSecurityContexts := dig "securityContexts" $globalValues (dict) -}}
137+
{{- $pod := mergeOverwrite (deepCopy (dig "pod" $globalSecurityContexts (dict))) (default (dict) $root.Values.podSecurityContext) -}}
138+
{{- $container := mergeOverwrite (deepCopy (dig "container" $globalSecurityContexts (dict))) (default (dict) $root.Values.securityContext) -}}
139+
{{- dict "pod" $pod "container" $container | toYaml -}}
140+
{{- end -}}

charts/network/charts/network-nodes/templates/statefulset-rpc.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ spec:
3636
{{- $initContainers := .Values.initContainers | default (dict) }}
3737
{{- $sharedInitContainers := get $initContainers "shared" }}
3838
{{- $rpcInitContainers := get $initContainers "rpc" }}
39-
{{- $globalValues := (.Values.global | default (dict)) }}
40-
{{- $globalSecurityContexts := dig "securityContexts" $globalValues (dict) }}
41-
{{- $podSecurityContext := merge (deepCopy (default (dict) .Values.podSecurityContext)) (dig "pod" $globalSecurityContexts (dict)) }}
42-
{{- $containerSecurityContext := merge (deepCopy (default (dict) .Values.securityContext)) (dig "container" $globalSecurityContexts (dict)) }}
39+
{{- $securityContexts := include "nodes.securityContexts" . | fromYaml }}
40+
{{- $podSecurityContext := index $securityContexts "pod" }}
41+
{{- $containerSecurityContext := index $securityContexts "container" }}
4342
podManagementPolicy: Parallel
4443
replicas: {{ .Values.rpcReplicaCount }}
4544
serviceName: {{ include "nodes.fullname" . }}-rpc

charts/network/charts/network-nodes/templates/statefulset-validator.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ spec:
3737
{{- $initContainers := .Values.initContainers | default (dict) }}
3838
{{- $sharedInitContainers := get $initContainers "shared" }}
3939
{{- $validatorInitContainers := get $initContainers "validator" }}
40-
{{- $globalValues := (.Values.global | default (dict)) }}
41-
{{- $globalSecurityContexts := dig "securityContexts" $globalValues (dict) }}
42-
{{- $podSecurityContext := merge (deepCopy (default (dict) .Values.podSecurityContext)) (dig "pod" $globalSecurityContexts (dict)) }}
43-
{{- $containerSecurityContext := merge (deepCopy (default (dict) .Values.securityContext)) (dig "container" $globalSecurityContexts (dict)) }}
40+
{{- $securityContexts := include "nodes.securityContexts" . | fromYaml }}
41+
{{- $podSecurityContext := index $securityContexts "pod" }}
42+
{{- $containerSecurityContext := index $securityContexts "container" }}
4443
podManagementPolicy: Parallel
4544
replicas: {{ $validatorReplicaBudget }}
4645
serviceName: {{ include "nodes.fullname" . }}

0 commit comments

Comments
 (0)