Skip to content

Commit 1f2388e

Browse files
Merge pull request #15924 from php-coder/scc_change_bootstrap_func_result
Automatic merge from submit-queue (batch tested with PRs 15964, 15624, 15924) GetBootstrapSecurityContextConstraints: change return type to a slice of pointers Extracted from #15923 (comment): It turned out that in all the places we need `[]*SecurityContextConstraints`. This PR updates `GetBootstrapSecurityContextConstraints` function to return this type. This change simplify our code. PTAL @pweil- @adelton CC @simo5
2 parents b897684 + a3cd039 commit 1f2388e

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

pkg/cmd/server/bootstrappolicy/securitycontextconstraints.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const (
4848
// GetBootstrapSecurityContextConstraints returns the slice of default SecurityContextConstraints
4949
// for system bootstrapping. This method takes additional users and groups that should be added
5050
// to the strategies. Use GetBoostrapSCCAccess to produce the default set of mappings.
51-
func GetBootstrapSecurityContextConstraints(sccNameToAdditionalGroups map[string][]string, sccNameToAdditionalUsers map[string][]string) []securityapi.SecurityContextConstraints {
51+
func GetBootstrapSecurityContextConstraints(sccNameToAdditionalGroups map[string][]string, sccNameToAdditionalUsers map[string][]string) []*securityapi.SecurityContextConstraints {
5252
// define priorities here and reference them below so it is easy to see, at a glance
5353
// what we're setting
5454
var (
@@ -57,7 +57,7 @@ func GetBootstrapSecurityContextConstraints(sccNameToAdditionalGroups map[string
5757
securityContextConstraintsAnyUIDPriority = int32(10)
5858
)
5959

60-
constraints := []securityapi.SecurityContextConstraints{
60+
constraints := []*securityapi.SecurityContextConstraints{
6161
// SecurityContextConstraintPrivileged allows all access for every field
6262
{
6363
ObjectMeta: metav1.ObjectMeta{

pkg/cmd/server/bootstrappolicy/securitycontextconstraints_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestBootstrappedConstraints(t *testing.T) {
4242
}
4343

4444
for _, expectedVolume := range expectedVolumes {
45-
if !sccutil.SCCAllowsFSType(&constraint, expectedVolume) {
45+
if !sccutil.SCCAllowsFSType(constraint, expectedVolume) {
4646
t.Errorf("%s does not support %v which is required for all default SCCs", constraint.Name, expectedVolume)
4747
}
4848
}

pkg/cmd/server/origin/openshift_apiserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ func (c *OpenshiftAPIConfig) bootstrapSCC(context genericapiserver.PostStartHook
475475
bootstrapSCCGroups, bootstrapSCCUsers := bootstrappolicy.GetBoostrapSCCAccess(ns)
476476

477477
for _, scc := range bootstrappolicy.GetBootstrapSecurityContextConstraints(bootstrapSCCGroups, bootstrapSCCUsers) {
478-
_, err := legacyclient.NewFromClient(c.KubeClientInternal.Core().RESTClient()).Create(&scc)
478+
_, err := legacyclient.NewFromClient(c.KubeClientInternal.Core().RESTClient()).Create(scc)
479479
if kapierror.IsAlreadyExists(err) {
480480
continue
481481
}

pkg/oc/admin/policy/reconcile_sccs.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ func (o *ReconcileSCCOptions) ChangedSCCs() ([]*securityapi.SecurityContextConst
177177
groups, users := bootstrappolicy.GetBoostrapSCCAccess(o.InfraNamespace)
178178
bootstrapSCCs := bootstrappolicy.GetBootstrapSecurityContextConstraints(groups, users)
179179

180-
for i := range bootstrapSCCs {
181-
expectedSCC := &bootstrapSCCs[i]
180+
for _, expectedSCC := range bootstrapSCCs {
182181
actualSCC, err := o.SCCClient.Get(expectedSCC.Name, metav1.GetOptions{})
183182
// if not found it needs to be created
184183
if kapierrors.IsNotFound(err) {

0 commit comments

Comments
 (0)