Skip to content

Commit

Permalink
add GlobalFloatingUserIdPath
Browse files Browse the repository at this point in the history
  • Loading branch information
sheidkamp committed Aug 8, 2024
1 parent 17c9f0d commit e6db081
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions codegen/model/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ type Operator struct {
//
// E.g: `and (.Values.operator.customValueA) (.Values.operator.customValueB)`
CustomEnableCondition string

// Optional: if specified, will use this path in rendering template logic
GlobalFloatingUserIdPath string
}

func (o Operator) FormattedName() string {
Expand Down
12 changes: 12 additions & 0 deletions codegen/templates/chart/operator-deployment.yamltmpl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ spec:
spec:
serviceAccountName: [[ $operator.Name ]]
{{- /* Override the default podSecurityContext config if it is set. */}}
[[- /* the GlobalFloatingUserId is expected to disable the pod security context */ -]]
[[- if $operator.GlobalFloatingUserIdPath ]]
{{- if not [[ $operator.GlobalFloatingUserIdPath ]] }}
[[- end ]]
{{- if or ([[ (opVar $operator) ]].podSecurityContext) (eq "map[]" (printf "%v" [[ (opVar $operator) ]].podSecurityContext)) }}
securityContext:
{{ toYaml [[ (opVar $operator) ]].podSecurityContext | indent 8 }}
Expand All @@ -96,6 +100,9 @@ spec:
[[ toYaml $podSecurityContext | indent 8 ]]
[[- end ]]
{{- end }}
[[- if $operator.GlobalFloatingUserIdPath ]] [[/* end the "if" if GlobalFloatingUserId is being checked */]]
{{- end }}
[[- end ]]
[[- if $volumes ]]
volumes:
[[ toYaml $volumes | indent 6 ]]
Expand Down Expand Up @@ -201,7 +208,12 @@ spec:
{}
{{- else}}
runAsNonRoot: true
[[- /* if there is a GlobalFloatingUserIdPath add it to the runAsuser logic */ -]]
[[- if $operator.GlobalFloatingUserIdPath ]]
{{- if not (or $[[ $operatorVar ]].floatingUserId [[ $operator.GlobalFloatingUserIdPath ]]) }}
[[- else ]]
{{- if not $[[ $operatorVar ]].floatingUserId }}
[[- end ]]
runAsUser: {{ printf "%.0f" (float64 $[[ $operatorVar ]].runAsUser) }}
{{- end }}
readOnlyRootFilesystem: true
Expand Down

0 comments on commit e6db081

Please sign in to comment.