mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 11:18:16 +00:00
set proper file permission for projected service account volume
This commit is contained in:
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
package securitycontext
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
// HasPrivilegedRequest returns the value of SecurityContext.Privileged, taking into account
|
||||
@@ -124,6 +124,25 @@ func DetermineEffectiveSecurityContext(pod *v1.Pod, container *v1.Container) *v1
|
||||
return effectiveSc
|
||||
}
|
||||
|
||||
// DetermineEffectiveRunAsUser returns a pointer of UID from the provided pod's
|
||||
// and container's security context and a bool value to indicate if it is absent.
|
||||
// Container's runAsUser take precedence in cases where both are set.
|
||||
func DetermineEffectiveRunAsUser(pod *v1.Pod, container *v1.Container) (*int64, bool) {
|
||||
var runAsUser *int64
|
||||
if pod.Spec.SecurityContext != nil && pod.Spec.SecurityContext.RunAsUser != nil {
|
||||
runAsUser = new(int64)
|
||||
*runAsUser = *pod.Spec.SecurityContext.RunAsUser
|
||||
}
|
||||
if container.SecurityContext != nil && container.SecurityContext.RunAsUser != nil {
|
||||
runAsUser = new(int64)
|
||||
*runAsUser = *container.SecurityContext.RunAsUser
|
||||
}
|
||||
if runAsUser == nil {
|
||||
return nil, false
|
||||
}
|
||||
return runAsUser, true
|
||||
}
|
||||
|
||||
func securityContextFromPodSecurityContext(pod *v1.Pod) *v1.SecurityContext {
|
||||
if pod.Spec.SecurityContext == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user