only set group when setting permissions (#783)
* only set group when setting permissions * fix test * another test fix
This commit is contained in:
@@ -18,4 +18,4 @@ maintainers:
|
||||
name: common
|
||||
sources: null
|
||||
type: library
|
||||
version: 6.8.1
|
||||
version: 6.8.2
|
||||
|
||||
@@ -5,13 +5,10 @@ before chart installation.
|
||||
{{- define "common.class.mountPermissions" -}}
|
||||
{{- if .Values.persistence -}}
|
||||
{{- $jobName := include "common.names.fullname" . -}}
|
||||
{{- $user := 568 -}}
|
||||
{{- $group := 568 -}}
|
||||
{{- if .Values.env -}}
|
||||
{{- $user = dig "PUID" $user .Values.env -}}
|
||||
{{- $group = dig "PGID" $group .Values.env -}}
|
||||
{{- end -}}
|
||||
{{- $user = dig "runAsUser" $user .Values.podSecurityContext -}}
|
||||
{{- $group = dig "fsGroup" $group .Values.podSecurityContext -}}
|
||||
{{- $hostPathMounts := dict -}}
|
||||
{{- range $name, $mount := .Values.persistence -}}
|
||||
@@ -45,7 +42,7 @@ spec:
|
||||
- -c
|
||||
- |
|
||||
{{- range $_, $hpm := $hostPathMounts }}
|
||||
chown -R {{ printf "%d:%d %s" (int $user) (int $group) $hpm.mountPath }}
|
||||
chown -R {{ printf ":%d %s" (int $group) $hpm.mountPath }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{- range $name, $hpm := $hostPathMounts }}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (suite *PermissionsJobTestSuite) TestCommand() {
|
||||
"DefaultPermissionsForMultipleMounts": {
|
||||
values: baseValues,
|
||||
expectedCommand: []string{
|
||||
"/bin/sh", "-c", "chown -R 568:568 /config\nchown -R 568:568 /data\n",
|
||||
"/bin/sh", "-c", "chown -R :568 /config\nchown -R :568 /data\n",
|
||||
},
|
||||
},
|
||||
"DefaultPermissionsForDisabledpodSecurityContext": {
|
||||
@@ -147,7 +147,7 @@ func (suite *PermissionsJobTestSuite) TestCommand() {
|
||||
"podSecurityContext.allowPrivilegeEscalation=false",
|
||||
),
|
||||
expectedCommand: []string{
|
||||
"/bin/sh", "-c", "chown -R 568:568 /config\nchown -R 568:568 /data\n",
|
||||
"/bin/sh", "-c", "chown -R :568 /config\nchown -R :568 /data\n",
|
||||
},
|
||||
},
|
||||
"PermissionsForFsGroup": {
|
||||
@@ -155,33 +155,15 @@ func (suite *PermissionsJobTestSuite) TestCommand() {
|
||||
"podSecurityContext.fsGroup=666",
|
||||
),
|
||||
expectedCommand: []string{
|
||||
"/bin/sh", "-c", "chown -R 568:666 /config\nchown -R 568:666 /data\n",
|
||||
"/bin/sh", "-c", "chown -R :666 /config\nchown -R :666 /data\n",
|
||||
},
|
||||
},
|
||||
"PermissionsForRunAsUser": {
|
||||
"PermissionsForPgid": {
|
||||
values: append(baseValues,
|
||||
"podSecurityContext.runAsUser=999",
|
||||
),
|
||||
expectedCommand: []string{
|
||||
"/bin/sh", "-c", "chown -R 999:568 /config\nchown -R 999:568 /data\n",
|
||||
},
|
||||
},
|
||||
"PermissionsForRunAsUserAndFsGroup": {
|
||||
values: append(baseValues,
|
||||
"podSecurityContext.runAsUser=999",
|
||||
"podSecurityContext.fsGroup=666",
|
||||
),
|
||||
expectedCommand: []string{
|
||||
"/bin/sh", "-c", "chown -R 999:666 /config\nchown -R 999:666 /data\n",
|
||||
},
|
||||
},
|
||||
"PermissionsForPgidPuid": {
|
||||
values: append(baseValues,
|
||||
"env.PUID=999",
|
||||
"env.PGID=666",
|
||||
),
|
||||
expectedCommand: []string{
|
||||
"/bin/sh", "-c", "chown -R 999:666 /config\nchown -R 999:666 /data\n",
|
||||
"/bin/sh", "-c", "chown -R :666 /config\nchown -R :666 /data\n",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user