Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPSTREAM: 21005: Use a different verb for delete collection #7209

Merged
merged 2 commits into from Feb 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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