Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
e2e: add UserWorkspace in pkg/context (#151)
Browse files Browse the repository at this point in the history
* e2e: add UserWorkspace in pkg/context

Signed-off-by: Francesco Ilario <filario@redhat.com>

* rollback RetrieveUserWorkspaces

Signed-off-by: Francesco Ilario <filario@redhat.com>

* rollback InjectUserWorkspaces

Signed-off-by: Francesco Ilario <filario@redhat.com>

---------

Signed-off-by: Francesco Ilario <filario@redhat.com>
Co-authored-by: Andy Sadler <ansadler@redhat.com>
  • Loading branch information
filariow and sadlerap authored May 22, 2024
1 parent 7244e71 commit 13d7685
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion e2e/pkg/context/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import (

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
"github.com/konflux-workspaces/workspaces/e2e/pkg/cli"
workspacesv1alpha1 "github.com/konflux-workspaces/workspaces/operator/api/v1alpha1"
"k8s.io/client-go/rest"

workspacesv1alpha1 "github.com/konflux-workspaces/workspaces/operator/api/v1alpha1"
restworkspacesv1alpha1 "github.com/konflux-workspaces/workspaces/server/api/v1alpha1"
)

type ContextKey string
Expand All @@ -20,6 +22,7 @@ const (
keyKubespaceNamespace ContextKey = "kubespace-namespace"
keyWorkspacesNamespace ContextKey = "workspaces-namespace"
keyInternalWorkspace ContextKey = "default-internal-workspace"
keyUserWorkspace ContextKey = "user-workspace"
keyUser ContextKey = "default-user"
keyUserWorkspaces ContextKey = "workspaces"

Expand Down Expand Up @@ -94,6 +97,18 @@ func RetrieveUser(ctx context.Context) toolchainv1alpha1.UserSignup {
}

// Workspaces
func InjectUserWorkspace(ctx context.Context, w restworkspacesv1alpha1.Workspace) context.Context {
return context.WithValue(ctx, keyUserWorkspace, w)
}

func RetrieveUserWorkspace(ctx context.Context) restworkspacesv1alpha1.Workspace {
return get[restworkspacesv1alpha1.Workspace](ctx, keyUserWorkspace)
}

func LookupUserWorkspace(ctx context.Context) (restworkspacesv1alpha1.Workspace, bool) {
return lookup[restworkspacesv1alpha1.Workspace](ctx, keyUserWorkspace)
}

func InjectUserWorkspaces(ctx context.Context, ww workspacesv1alpha1.InternalWorkspaceList) context.Context {
return context.WithValue(ctx, keyUserWorkspaces, ww)
}
Expand Down

0 comments on commit 13d7685

Please sign in to comment.