Skip to content

Commit

Permalink
Merge branch 'master' into useraccount-in-mur-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MatousJobanek authored Oct 3, 2023
2 parents 4d52ef0 + bf3a59c commit 566025e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 6 additions & 0 deletions pkg/proxy/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions pkg/proxy/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
})
}

0 comments on commit 566025e

Please sign in to comment.