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

update bootstrappolicy/dead addDeadClusterRole to include systemOnly annotation #15320

Merged
merged 1 commit into from
Jul 19, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/cmd/server/bootstrappolicy/dead.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ func addDeadClusterRole(name string) {

deadClusterRoles = append(deadClusterRoles,
authorizationapi.ClusterRole{
ObjectMeta: metav1.ObjectMeta{Name: name},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Annotations: map[string]string{
roleSystemOnly: roleIsSystemOnly,
},
},
},
)
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/cmd/server/bootstrappolicy/web_console_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ func TestSystemOnlyRoles(t *testing.T) {

for _, role := range GetBootstrapClusterRoles() {
if isControllerRole(&role) {
continue // assume all controller roles can be ignored
if !isSystemOnlyRole(&role) {
t.Errorf("Controller role %q is missing the system only annotation", role.Name)
}
continue // assume all controller roles can be ignored even though we require the annotation
}
if isSystemOnlyRole(role) {
if isSystemOnlyRole(&role) {
hide.Insert(role.Name)
} else {
show.Insert(role.Name)
Expand All @@ -86,7 +89,7 @@ func TestSystemOnlyRoles(t *testing.T) {

// this logic must stay in sync w/the web console for this test to be valid/valuable
// it is the same logic that is run on the membership page
func isSystemOnlyRole(role authorizationapi.ClusterRole) bool {
func isSystemOnlyRole(role *authorizationapi.ClusterRole) bool {
return role.Annotations[roleSystemOnly] == roleIsSystemOnly
}

Expand Down
30 changes: 30 additions & 0 deletions test/testdata/bootstrappolicy/bootstrap_cluster_roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2838,90 +2838,120 @@ items:
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:replication-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:endpoint-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:replicaset-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:garbage-collector-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:job-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:hpa-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:daemonset-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:disruption-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:namespace-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:gc-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:certificate-signing-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:statefulset-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:build-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:deploymentconfig-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:deployment-controller
rules: []
Expand Down