PodSecurityPolicy: avoid unnecessary mutation of supplemental groups

parent cfb490e3
...@@ -34,7 +34,7 @@ func NewRunAsAny() (GroupStrategy, error) { ...@@ -34,7 +34,7 @@ func NewRunAsAny() (GroupStrategy, error) {
// Generate creates the group based on policy rules. This strategy returns an empty slice. // Generate creates the group based on policy rules. This strategy returns an empty slice.
func (s *runAsAny) Generate(pod *api.Pod) ([]int64, error) { func (s *runAsAny) Generate(pod *api.Pod) ([]int64, error) {
return []int64{}, nil return nil, nil
} }
// Generate a single value to be applied. This is used for FSGroup. This strategy returns nil. // Generate a single value to be applied. This is used for FSGroup. This strategy returns nil.
......
...@@ -80,7 +80,7 @@ func (s *simpleProvider) CreatePodSecurityContext(pod *api.Pod) (*api.PodSecurit ...@@ -80,7 +80,7 @@ func (s *simpleProvider) CreatePodSecurityContext(pod *api.Pod) (*api.PodSecurit
} }
annotations := maps.CopySS(pod.Annotations) annotations := maps.CopySS(pod.Annotations)
if len(sc.SupplementalGroups) == 0 { if sc.SupplementalGroups == nil {
supGroups, err := s.strategies.SupplementalGroupStrategy.Generate(pod) supGroups, err := s.strategies.SupplementalGroupStrategy.Generate(pod)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
......
...@@ -993,7 +993,7 @@ func TestAdmitSupplementalGroups(t *testing.T) { ...@@ -993,7 +993,7 @@ func TestAdmitSupplementalGroups(t *testing.T) {
pod: goodPod(), pod: goodPod(),
psps: []*extensions.PodSecurityPolicy{runAsAny}, psps: []*extensions.PodSecurityPolicy{runAsAny},
shouldPass: true, shouldPass: true,
expectedSupGroups: []int64{}, expectedSupGroups: nil,
expectedPSP: runAsAny.Name, expectedPSP: runAsAny.Name,
}, },
"runAsAny pod request": { "runAsAny pod request": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment