Skip to content

Commit

Permalink
Merge pull request #15924 from php-coder/scc_change_bootstrap_func_re…
Browse files Browse the repository at this point in the history
…sult

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
  • Loading branch information
openshift-merge-robot committed Aug 28, 2017
2 parents b897684 + a3cd039 commit 1f2388e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/cmd/server/bootstrappolicy/securitycontextconstraints.go
Expand Up @@ -48,7 +48,7 @@ const (
// GetBootstrapSecurityContextConstraints returns the slice of default SecurityContextConstraints
// for system bootstrapping. This method takes additional users and groups that should be added
// to the strategies. Use GetBoostrapSCCAccess to produce the default set of mappings.
func GetBootstrapSecurityContextConstraints(sccNameToAdditionalGroups map[string][]string, sccNameToAdditionalUsers map[string][]string) []securityapi.SecurityContextConstraints {
func GetBootstrapSecurityContextConstraints(sccNameToAdditionalGroups map[string][]string, sccNameToAdditionalUsers map[string][]string) []*securityapi.SecurityContextConstraints {
// define priorities here and reference them below so it is easy to see, at a glance
// what we're setting
var (
Expand All @@ -57,7 +57,7 @@ func GetBootstrapSecurityContextConstraints(sccNameToAdditionalGroups map[string
securityContextConstraintsAnyUIDPriority = int32(10)
)

constraints := []securityapi.SecurityContextConstraints{
constraints := []*securityapi.SecurityContextConstraints{
// SecurityContextConstraintPrivileged allows all access for every field
{
ObjectMeta: metav1.ObjectMeta{
Expand Down
Expand Up @@ -42,7 +42,7 @@ func TestBootstrappedConstraints(t *testing.T) {
}

for _, expectedVolume := range expectedVolumes {
if !sccutil.SCCAllowsFSType(&constraint, expectedVolume) {
if !sccutil.SCCAllowsFSType(constraint, expectedVolume) {
t.Errorf("%s does not support %v which is required for all default SCCs", constraint.Name, expectedVolume)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/origin/openshift_apiserver.go
Expand Up @@ -475,7 +475,7 @@ func (c *OpenshiftAPIConfig) bootstrapSCC(context genericapiserver.PostStartHook
bootstrapSCCGroups, bootstrapSCCUsers := bootstrappolicy.GetBoostrapSCCAccess(ns)

for _, scc := range bootstrappolicy.GetBootstrapSecurityContextConstraints(bootstrapSCCGroups, bootstrapSCCUsers) {
_, err := legacyclient.NewFromClient(c.KubeClientInternal.Core().RESTClient()).Create(&scc)
_, err := legacyclient.NewFromClient(c.KubeClientInternal.Core().RESTClient()).Create(scc)
if kapierror.IsAlreadyExists(err) {
continue
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/oc/admin/policy/reconcile_sccs.go
Expand Up @@ -177,8 +177,7 @@ func (o *ReconcileSCCOptions) ChangedSCCs() ([]*securityapi.SecurityContextConst
groups, users := bootstrappolicy.GetBoostrapSCCAccess(o.InfraNamespace)
bootstrapSCCs := bootstrappolicy.GetBootstrapSecurityContextConstraints(groups, users)

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

0 comments on commit 1f2388e

Please sign in to comment.