File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,13 +16,16 @@ package cache
1616import (
1717 "fmt"
1818
19+ "github.com/devfile/devworkspace-operator/pkg/common"
1920 "github.com/devfile/devworkspace-operator/pkg/constants"
2021 "github.com/devfile/devworkspace-operator/pkg/infrastructure"
2122 routev1 "github.com/openshift/api/route/v1"
2223 appsv1 "k8s.io/api/apps/v1"
2324 batchv1 "k8s.io/api/batch/v1"
2425 corev1 "k8s.io/api/core/v1"
2526 networkingv1 "k8s.io/api/networking/v1"
27+ rbacv1 "k8s.io/api/rbac/v1"
28+ "k8s.io/apimachinery/pkg/fields"
2629 "k8s.io/apimachinery/pkg/labels"
2730 "sigs.k8s.io/controller-runtime/pkg/cache"
2831)
@@ -71,6 +74,12 @@ func GetCacheFunc() (cache.NewCacheFunc, error) {
7174 & corev1.Secret {}: {
7275 Label : secretObjectSelector ,
7376 },
77+ & rbacv1.Role {}: {
78+ Field : fields .SelectorFromSet (fields.Set {"metadata.name" : common .WorkspaceRoleName ()}),
79+ },
80+ & rbacv1.RoleBinding {}: {
81+ Field : fields .SelectorFromSet (fields.Set {"metadata.name" : common .WorkspaceRolebindingName ()}),
82+ },
7483 }
7584
7685 if infrastructure .IsOpenShift () {
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ import (
1919 "fmt"
2020 "regexp"
2121 "strings"
22+
23+ "github.com/devfile/devworkspace-operator/pkg/constants"
2224)
2325
2426var NonAlphaNumRegexp = regexp .MustCompile (`[^a-z0-9]+` )
@@ -95,3 +97,11 @@ func AutoMountSecretVolumeName(volumeName string) string {
9597func AutoMountPVCVolumeName (pvcName string ) string {
9698 return fmt .Sprintf ("automount-pvc-%s" , pvcName )
9799}
100+
101+ func WorkspaceRoleName () string {
102+ return "workspace"
103+ }
104+
105+ func WorkspaceRolebindingName () string {
106+ return constants .ServiceAccount + "dw"
107+ }
Original file line number Diff line number Diff line change @@ -17,10 +17,9 @@ package workspace
1717
1818import (
1919 dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
20+ "github.com/devfile/devworkspace-operator/pkg/common"
2021 "github.com/devfile/devworkspace-operator/pkg/provision/sync"
2122
22- "github.com/devfile/devworkspace-operator/pkg/constants"
23-
2423 rbacv1 "k8s.io/api/rbac/v1"
2524 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2625 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -52,7 +51,7 @@ func generateRBAC(namespace string) []client.Object {
5251 return []client.Object {
5352 & rbacv1.Role {
5453 ObjectMeta : metav1.ObjectMeta {
55- Name : "workspace" ,
54+ Name : common . WorkspaceRoleName () ,
5655 Namespace : namespace ,
5756 },
5857 Rules : []rbacv1.PolicyRule {
@@ -96,7 +95,7 @@ func generateRBAC(namespace string) []client.Object {
9695 },
9796 & rbacv1.RoleBinding {
9897 ObjectMeta : metav1.ObjectMeta {
99- Name : constants . ServiceAccount + "-dw" ,
98+ Name : common . WorkspaceRolebindingName () ,
10099 Namespace : namespace ,
101100 },
102101 RoleRef : rbacv1.RoleRef {
You can’t perform that action at this time.
0 commit comments