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 2 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

### Changed
- Upgrade minimal Ansible version in the init projects from `2.4` to `2.6`. ([#2107](https://github.com/operator-framework/operator-sdk/pull/2107))
- Replace `*` per verbs for roles generated. ([#2175](https://github.com/operator-framework/operator-sdk/pull/2175))
camilamacedo86 marked this conversation as resolved.
Show resolved Hide resolved

### Deprecated

Expand All @@ -22,7 +23,7 @@

### Changed

- **Breaking change:** Changed required Go version from `1.12` to `1.13`. This change applies to the SDK project itself and Go projects scaffolded by the SDK. Projects that import this version of the SDK require Go 1.13 to compile. ([#1949](https://github.com/operator-framework/operator-sdk/pull/1949))
- **Breaking change:** Changed required Go version from `1.12` to `1.13`. This change applies to the SDK project itself and Go projects scaffolded by the SDK. Projects that import this version of the SDK require Go 1.13 to compile. ([#1949](https://github.com/operator-framework/operator-sdk/pull/1949))

### Deprecated
camilamacedo86 marked this conversation as resolved.
Show resolved Hide resolved
- Upgrade Kubernetes version from `kubernetes-1.14.1` to `kubernetes-1.15.4`. ([#2083](https://github.com/operator-framework/operator-sdk/pull/2083))
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)
}
// update role.yaml
Expand Down Expand Up @@ -130,7 +138,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)
}
// update role.yaml
Expand Down Expand Up @@ -172,7 +188,13 @@ rules:
- configmaps
- secrets
verbs:
- "*"
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
Expand All @@ -181,7 +203,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