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

fix(issue 671): Generated Role.yaml and RoleBinding.yaml don't work w… #2175

Merged
merged 5 commits into from
Dec 3, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Replace in the Ansible based operators module tests `k8s_info` for `k8s_facts` which is deprecated. ([#2168](https://github.com/operator-framework/operator-sdk/issues/2168))
- Upgrade the Ansible version from `2.8` to `2.9` on the Ansible based operators image. ([#2168](https://github.com/operator-framework/operator-sdk/issues/2168))
- Updated CRD generation for non-Go operators to use valid structural schema. ([#2275](https://github.com/operator-framework/operator-sdk/issues/2275))
- Replace Role verb `"*"` with list of verb strings in generated files so the Role is compatible with OpenShift and Kubernetes. ([#2175](https://github.com/operator-framework/operator-sdk/pull/2175))

### Deprecated

Expand Down
36 changes: 32 additions & 4 deletions internal/scaffold/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ func UpdateRoleForResource(r *Resource, absProjectPath string) error {
// Using "*" to allow access to the resource and all its subresources e.g "memcacheds" and "memcacheds/finalizers"
// https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#ownerreferencespermissionenforcement
pr.Resources = []string{"*"}
pr.Verbs = []string{"*"}
pr.Verbs = []string{
"create",
"delete",
"get",
"list",
"patch",
"update",
"watch",
}
role.Rules = append(role.Rules, *pr)
}

Expand Down Expand Up @@ -116,7 +124,15 @@ func UpdateRoleForResource(r *Resource, absProjectPath string) error {
// Using "*" to allow access to the resource and all its subresources e.g "memcacheds" and "memcacheds/finalizers"
// https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#ownerreferencespermissionenforcement
pr.Resources = []string{"*"}
pr.Verbs = []string{"*"}
pr.Verbs = []string{
"create",
"delete",
"get",
"list",
"patch",
"update",
"watch",
}
role.Rules = append(role.Rules, *pr)
}

Expand Down Expand Up @@ -164,7 +180,13 @@ rules:
- configmaps
- secrets
verbs:
- "*"
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
Expand All @@ -173,7 +195,13 @@ rules:
- replicasets
- statefulsets
verbs:
- "*"
- create
- delete
- get
- list
- patch
- update
- watch
{{- end }}
{{- range .CustomRules }}
- verbs:
Expand Down
50 changes: 44 additions & 6 deletions internal/scaffold/role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ func TestRoleCustomRules(t *testing.T) {
{
APIGroups: []string{"policy"},
Resources: []string{"poddisruptionbudgets"},
Verbs: []string{rbacv1.VerbAll},
Verbs: []string{
"create",
"delete",
"get",
"list",
"patch",
"update",
"watch",
},
},
{
APIGroups: []string{"rbac.authorization.k8s.io"},
Expand Down Expand Up @@ -91,7 +99,13 @@ rules:
- configmaps
- secrets
verbs:
- "*"
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
Expand All @@ -100,7 +114,13 @@ rules:
- replicasets
- statefulsets
verbs:
- "*"
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- monitoring.coreos.com
resources:
Expand Down Expand Up @@ -148,7 +168,13 @@ rules:
- configmaps
- secrets
verbs:
- "*"
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
Expand All @@ -157,7 +183,13 @@ rules:
- replicasets
- statefulsets
verbs:
- "*"
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- monitoring.coreos.com
resources:
Expand Down Expand Up @@ -194,7 +226,13 @@ metadata:
name: app-operator
rules:
- verbs:
- "*"
- "create"
- "delete"
- "get"
- "list"
- "patch"
- "update"
- "watch"
apiGroups:
- "policy"
resources:
Expand Down