Skip to content

Commit 26ae2a6

Browse files
committed
Consume workspace label key from helper
Updates the Workspace handlers to consume label key from a common location. Signed-off-by: hasheddan <[email protected]>
1 parent 544faaf commit 26ae2a6

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

pkg/virtual/workspaces/registry/rest.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ import (
5353
workspaceutil "github.com/kcp-dev/kcp/pkg/virtual/workspaces/util"
5454
)
5555

56-
const (
57-
WorkspaceNameLabel string = "workspaces.kcp.dev/name"
58-
)
59-
6056
// FilteredClusterWorkspaces allows to list and watch ClusterWorkspaces
6157
// filtered by authorizaation, i.e. a user only sees those object he has access to.
6258
type FilteredClusterWorkspaces interface {
@@ -354,7 +350,7 @@ func (s *REST) Create(ctx context.Context, obj runtime.Object, createValidation
354350
ObjectMeta: metav1.ObjectMeta{
355351
Name: ownerRoleBindingName,
356352
Labels: map[string]string{
357-
WorkspaceNameLabel: workspace.Name,
353+
tenancyv1beta1.WorkspaceNameLabel: workspace.Name,
358354
},
359355
},
360356
RoleRef: rbacv1.RoleRef{
@@ -388,7 +384,7 @@ func (s *REST) Create(ctx context.Context, obj runtime.Object, createValidation
388384
ObjectMeta: metav1.ObjectMeta{
389385
Name: ownerRoleBindingName,
390386
Labels: map[string]string{
391-
WorkspaceNameLabel: workspace.Name,
387+
tenancyv1beta1.WorkspaceNameLabel: workspace.Name,
392388
},
393389
},
394390
Rules: rules,

pkg/virtual/workspaces/registry/rest_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func TestListWorkspacesWithGroupPermission(t *testing.T) {
254254
logicalcluster.AnnotationKey: "root:orgName",
255255
},
256256
Labels: map[string]string{
257-
WorkspaceNameLabel: "foo",
257+
tenancyv1beta1.WorkspaceNameLabel: "foo",
258258
},
259259
},
260260
Subjects: []rbacv1.Subject{
@@ -324,7 +324,7 @@ func TestListWorkspacesWithUserPermission(t *testing.T) {
324324
logicalcluster.AnnotationKey: "root:orgName",
325325
},
326326
Labels: map[string]string{
327-
WorkspaceNameLabel: "foo",
327+
tenancyv1beta1.WorkspaceNameLabel: "foo",
328328
},
329329
},
330330
Subjects: []rbacv1.Subject{
@@ -433,7 +433,7 @@ func TestGetWorkspace(t *testing.T) {
433433
logicalcluster.AnnotationKey: "root:orgName",
434434
},
435435
Labels: map[string]string{
436-
WorkspaceNameLabel: "foo",
436+
tenancyv1beta1.WorkspaceNameLabel: "foo",
437437
},
438438
},
439439
Subjects: []rbacv1.Subject{
@@ -514,7 +514,7 @@ func TestGetWorkspaceNotFoundNoPermission(t *testing.T) {
514514
logicalcluster.AnnotationKey: "root:orgName",
515515
},
516516
Labels: map[string]string{
517-
WorkspaceNameLabel: "foo",
517+
tenancyv1beta1.WorkspaceNameLabel: "foo",
518518
},
519519
},
520520
Subjects: []rbacv1.Subject{
@@ -576,7 +576,7 @@ func TestCreateWorkspace(t *testing.T) {
576576
ObjectMeta: metav1.ObjectMeta{
577577
Name: "owner-workspace-foo-test-user",
578578
Labels: map[string]string{
579-
WorkspaceNameLabel: "foo",
579+
tenancyv1beta1.WorkspaceNameLabel: "foo",
580580
},
581581
},
582582
RoleRef: rbacv1.RoleRef{
@@ -600,7 +600,7 @@ func TestCreateWorkspace(t *testing.T) {
600600
ObjectMeta: metav1.ObjectMeta{
601601
Name: "owner-workspace-foo-test-user",
602602
Labels: map[string]string{
603-
WorkspaceNameLabel: "foo",
603+
tenancyv1beta1.WorkspaceNameLabel: "foo",
604604
},
605605
},
606606
Rules: []rbacv1.PolicyRule{
@@ -663,7 +663,7 @@ func TestCreateWorkspaceWithCreateAnyPermission(t *testing.T) {
663663
ObjectMeta: metav1.ObjectMeta{
664664
Name: "owner-workspace-foo-test-user",
665665
Labels: map[string]string{
666-
WorkspaceNameLabel: "foo",
666+
tenancyv1beta1.WorkspaceNameLabel: "foo",
667667
},
668668
},
669669
RoleRef: rbacv1.RoleRef{
@@ -687,7 +687,7 @@ func TestCreateWorkspaceWithCreateAnyPermission(t *testing.T) {
687687
ObjectMeta: metav1.ObjectMeta{
688688
Name: "owner-workspace-foo-test-user",
689689
Labels: map[string]string{
690-
WorkspaceNameLabel: "foo",
690+
tenancyv1beta1.WorkspaceNameLabel: "foo",
691691
},
692692
},
693693
Rules: []rbacv1.PolicyRule{
@@ -759,7 +759,7 @@ func TestCreateWorkspaceCustomLocalType(t *testing.T) {
759759
ObjectMeta: metav1.ObjectMeta{
760760
Name: "owner-workspace-foo-test-user",
761761
Labels: map[string]string{
762-
WorkspaceNameLabel: "foo",
762+
tenancyv1beta1.WorkspaceNameLabel: "foo",
763763
},
764764
},
765765
RoleRef: rbacv1.RoleRef{
@@ -783,7 +783,7 @@ func TestCreateWorkspaceCustomLocalType(t *testing.T) {
783783
ObjectMeta: metav1.ObjectMeta{
784784
Name: "owner-workspace-foo-test-user",
785785
Labels: map[string]string{
786-
WorkspaceNameLabel: "foo",
786+
tenancyv1beta1.WorkspaceNameLabel: "foo",
787787
},
788788
},
789789
Rules: []rbacv1.PolicyRule{
@@ -849,7 +849,7 @@ func TestCreateWorkspaceNameAlreadyExists(t *testing.T) {
849849
logicalcluster.AnnotationKey: "root:orgName",
850850
},
851851
Labels: map[string]string{
852-
WorkspaceNameLabel: "foo",
852+
tenancyv1beta1.WorkspaceNameLabel: "foo",
853853
},
854854
},
855855
Subjects: []rbacv1.Subject{
@@ -868,7 +868,7 @@ func TestCreateWorkspaceNameAlreadyExists(t *testing.T) {
868868
logicalcluster.AnnotationKey: "root:orgName",
869869
},
870870
Labels: map[string]string{
871-
WorkspaceNameLabel: "foo",
871+
tenancyv1beta1.WorkspaceNameLabel: "foo",
872872
},
873873
},
874874
Rules: []rbacv1.PolicyRule{
@@ -1004,7 +1004,7 @@ func TestDeleteWorkspaceNotFound(t *testing.T) {
10041004
logicalcluster.AnnotationKey: "root:orgName",
10051005
},
10061006
Labels: map[string]string{
1007-
WorkspaceNameLabel: "foo",
1007+
tenancyv1beta1.WorkspaceNameLabel: "foo",
10081008
},
10091009
},
10101010
Subjects: []rbacv1.Subject{
@@ -1023,7 +1023,7 @@ func TestDeleteWorkspaceNotFound(t *testing.T) {
10231023
logicalcluster.AnnotationKey: "root:orgName",
10241024
},
10251025
Labels: map[string]string{
1026-
WorkspaceNameLabel: "foo",
1026+
tenancyv1beta1.WorkspaceNameLabel: "foo",
10271027
},
10281028
},
10291029
Rules: []rbacv1.PolicyRule{
@@ -1101,7 +1101,7 @@ func TestDeleteWorkspace(t *testing.T) {
11011101
logicalcluster.AnnotationKey: "root:orgName",
11021102
},
11031103
Labels: map[string]string{
1104-
WorkspaceNameLabel: "foo",
1104+
tenancyv1beta1.WorkspaceNameLabel: "foo",
11051105
},
11061106
},
11071107
Subjects: []rbacv1.Subject{
@@ -1120,7 +1120,7 @@ func TestDeleteWorkspace(t *testing.T) {
11201120
logicalcluster.AnnotationKey: "root:orgName",
11211121
},
11221122
Labels: map[string]string{
1123-
WorkspaceNameLabel: "foo",
1123+
tenancyv1beta1.WorkspaceNameLabel: "foo",
11241124
},
11251125
},
11261126
Rules: []rbacv1.PolicyRule{

0 commit comments

Comments
 (0)