Skip to content

Commit

Permalink
Add deletecollection verb to admin/edit roles
Browse files Browse the repository at this point in the history
  • Loading branch information
liggitt committed Feb 17, 2016
1 parent 4db577d commit a685817
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
8 changes: 4 additions & 4 deletions pkg/cmd/server/bootstrappolicy/policy.go
Expand Up @@ -100,12 +100,12 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
},
Rules: []authorizationapi.PolicyRule{
{
Verbs: sets.NewString("get", "list", "watch", "create", "update", "patch", "delete"),
Verbs: sets.NewString("get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"),
Resources: sets.NewString(authorizationapi.OpenshiftExposedGroupName, authorizationapi.PermissionGrantingGroupName, authorizationapi.KubeExposedGroupName, "projects", "secrets", "pods/attach", "pods/proxy", "pods/exec", "pods/portforward", authorizationapi.DockerBuildResource, authorizationapi.SourceBuildResource, authorizationapi.CustomBuildResource, "deploymentconfigs/scale"),
},
{
APIGroups: []string{authorizationapi.APIGroupExtensions},
Verbs: sets.NewString("get", "list", "watch", "create", "update", "patch", "delete"),
Verbs: sets.NewString("get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"),
Resources: sets.NewString("daemonsets", "jobs", "horizontalpodautoscalers", "replicationcontrollers/scale"),
},
{
Expand All @@ -130,12 +130,12 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
},
Rules: []authorizationapi.PolicyRule{
{
Verbs: sets.NewString("get", "list", "watch", "create", "update", "patch", "delete"),
Verbs: sets.NewString("get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"),
Resources: sets.NewString(authorizationapi.OpenshiftExposedGroupName, authorizationapi.KubeExposedGroupName, "secrets", "pods/attach", "pods/proxy", "pods/exec", "pods/portforward", authorizationapi.DockerBuildResource, authorizationapi.SourceBuildResource, authorizationapi.CustomBuildResource, "deploymentconfigs/scale"),
},
{
APIGroups: []string{authorizationapi.APIGroupExtensions},
Verbs: sets.NewString("get", "list", "watch", "create", "update", "patch", "delete"),
Verbs: sets.NewString("get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"),
Resources: sets.NewString("daemonsets", "jobs", "horizontalpodautoscalers", "replicationcontrollers/scale"),
},
{
Expand Down
22 changes: 15 additions & 7 deletions pkg/cmd/server/bootstrappolicy/policy_test.go
@@ -1,8 +1,8 @@
package bootstrappolicy_test

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -75,11 +75,19 @@ func testObjects(t *testing.T, list *api.List, fixtureFilename string) {
t.Fatal(err)
}
if string(yamlData) != string(expectedYAML) {
fmt.Println("Bootstrap policy data does not match the test fixture in " + filename)
fmt.Println("If the change is expected, update the fixture with this bootstrap policy data:")
fmt.Println("-----------------------------------")
fmt.Println(string(yamlData))
fmt.Println("-----------------------------------")
t.Errorf("Diff between bootstrap data and fixture data in %s:\n-------------\n%s", filename, util.StringDiff(string(yamlData), string(expectedYAML)))
t.Errorf("Bootstrap policy data does not match the test fixture in %s", filename)

const updateEnvVar = "UPDATE_BOOTSTRAP_POLICY_FIXTURE_DATA"
if os.Getenv(updateEnvVar) == "true" {
if err := ioutil.WriteFile(filename, []byte(yamlData), os.FileMode(0755)); err == nil {
t.Logf("Updated data in %s", filename)
t.Logf("Verify the diff, commit changes, and rerun the tests")
} else {
t.Logf("Could not update data in %s: %v", filename, err)
}
} else {
t.Logf("Diff between bootstrap data and fixture data in %s:\n-------------\n%s", filename, util.StringDiff(string(yamlData), string(expectedYAML)))
t.Logf("If the change is expected, re-run with %s=true to update the fixtures", updateEnvVar)
}
}
}
4 changes: 4 additions & 0 deletions test/fixtures/bootstrappolicy/bootstrap_cluster_roles.yaml
Expand Up @@ -196,6 +196,7 @@ items:
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand All @@ -212,6 +213,7 @@ items:
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand Down Expand Up @@ -312,6 +314,7 @@ items:
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand All @@ -328,6 +331,7 @@ items:
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand Down

0 comments on commit a685817

Please sign in to comment.