Skip to content

Commit

Permalink
Begin process of deprecating previous role and rolebinding functionality
Browse files Browse the repository at this point in the history
The default way to provision roles and rolebindings in DevWorkspace
namespaces was by creating roles and bindings with static names. This
needs to be extended and so the previous way of provisioning needs to be
safely deprecated.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
  • Loading branch information
amisevsk committed Nov 7, 2022
1 parent ac944d5 commit 5610c8c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ func GetCacheFunc() (cache.NewCacheFunc, error) {
Label: secretObjectSelector,
},
&rbacv1.Role{}: {
Field: fields.SelectorFromSet(fields.Set{"metadata.name": common.WorkspaceRoleName()}),
Field: fields.SelectorFromSet(fields.Set{"metadata.name": common.OldWorkspaceRoleName()}),
},
&rbacv1.RoleBinding{}: {
Field: fields.SelectorFromSet(fields.Set{"metadata.name": common.WorkspaceRolebindingName()}),
Field: fields.SelectorFromSet(fields.Set{"metadata.name": common.OldWorkspaceRolebindingName()}),
},
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/common/naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ func MetadataConfigMapName(workspaceId string) string {
// can potentially push the name over the 63 character limit (if the original
// object has a long name)
func AutoMountConfigMapVolumeName(volumeName string) string {
return fmt.Sprintf("%s", volumeName)
return volumeName
}

func AutoMountSecretVolumeName(volumeName string) string {
return fmt.Sprintf("%s", volumeName)
return volumeName
}

func AutoMountPVCVolumeName(pvcName string) string {
return fmt.Sprintf("%s", pvcName)
return pvcName
}

func WorkspaceRoleName() string {
func OldWorkspaceRoleName() string {
return "workspace"
}

func WorkspaceRolebindingName() string {
func OldWorkspaceRolebindingName() string {
return constants.ServiceAccount + "dw"
}
4 changes: 2 additions & 2 deletions pkg/provision/workspace/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func generateRBAC(namespace string) []client.Object {
return []client.Object{
&rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{
Name: common.WorkspaceRoleName(),
Name: common.OldWorkspaceRoleName(),
Namespace: namespace,
},
Rules: []rbacv1.PolicyRule{
Expand Down Expand Up @@ -106,7 +106,7 @@ func generateRBAC(namespace string) []client.Object {
},
&rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: common.WorkspaceRolebindingName(),
Name: common.OldWorkspaceRolebindingName(),
Namespace: namespace,
},
RoleRef: rbacv1.RoleRef{
Expand Down

0 comments on commit 5610c8c

Please sign in to comment.