diff --git a/go.mod b/go.mod index 0674dfc7..fd7a71b4 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/codeready-toolchain/toolchain-common go 1.19 require ( - github.com/codeready-toolchain/api v0.0.0-20230912073725-4ae0201b4630 + github.com/codeready-toolchain/api v0.0.0-20230918195153-739e8fb09a33 github.com/go-logr/logr v1.2.3 github.com/gofrs/uuid v3.3.0+incompatible github.com/golang-jwt/jwt v3.2.2+incompatible diff --git a/go.sum b/go.sum index c940a229..20881a2f 100644 --- a/go.sum +++ b/go.sum @@ -115,8 +115,8 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= -github.com/codeready-toolchain/api v0.0.0-20230912073725-4ae0201b4630 h1:Z281nLD0OLfdzbUq2tUK5/B6d2OX1hPg5oFGZSJM4RQ= -github.com/codeready-toolchain/api v0.0.0-20230912073725-4ae0201b4630/go.mod h1:nn3W6eKb9PFIVwSwZW7wDeLACMBOwAV+4kddGuN+ARM= +github.com/codeready-toolchain/api v0.0.0-20230918195153-739e8fb09a33 h1:hxXfcFq2JgFISVxrkISg8m9DZMzpcPWRjPspx3M3Sxo= +github.com/codeready-toolchain/api v0.0.0-20230918195153-739e8fb09a33/go.mod h1:nn3W6eKb9PFIVwSwZW7wDeLACMBOwAV+4kddGuN+ARM= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= diff --git a/pkg/proxy/workspace.go b/pkg/proxy/workspace.go index 50a7d52d..cdcd72a4 100644 --- a/pkg/proxy/workspace.go +++ b/pkg/proxy/workspace.go @@ -51,6 +51,12 @@ func WithType(wsType string) WorkspaceOption { } } +func WithAvailableRoles(roles []string) WorkspaceOption { + return func(workspace *toolchainv1alpha1.Workspace) { + workspace.Status.AvailableRoles = roles + } +} + func WithObjectMetaFrom(from metav1.ObjectMeta) WorkspaceOption { return func(workspace *toolchainv1alpha1.Workspace) { workspace.ObjectMeta.ResourceVersion = from.ResourceVersion diff --git a/pkg/proxy/workspace_test.go b/pkg/proxy/workspace_test.go index 249f39b2..8d3c365f 100644 --- a/pkg/proxy/workspace_test.go +++ b/pkg/proxy/workspace_test.go @@ -25,12 +25,14 @@ func TestNewWorkspace(t *testing.T) { t.Run("with options", func(t *testing.T) { // given // when - workspace := proxy.NewWorkspace("test", proxy.WithOwner("john"), proxy.WithRole("admin"), proxy.WithNamespaces([]toolchainv1alpha1.SpaceNamespace{ - { - Name: "john-tenant", - Type: "default", - }, - })) + expectedAvailableRoles := []string{"admin", "viewer"} + workspace := proxy.NewWorkspace("test", proxy.WithOwner("john"), proxy.WithRole("admin"), proxy.WithAvailableRoles(expectedAvailableRoles), + proxy.WithNamespaces([]toolchainv1alpha1.SpaceNamespace{ + { + Name: "john-tenant", + Type: "default", + }, + })) // then require.Equal(t, "Workspace", workspace.Kind) @@ -40,5 +42,6 @@ func TestNewWorkspace(t *testing.T) { require.Len(t, workspace.Status.Namespaces, 1) require.Equal(t, "john-tenant", workspace.Status.Namespaces[0].Name) require.Equal(t, "default", workspace.Status.Namespaces[0].Type) + require.Equal(t, expectedAvailableRoles, workspace.Status.AvailableRoles) }) }