From 188bd3ab7e664f7e44dfbe1c2954734e80e92f07 Mon Sep 17 00:00:00 2001 From: Atanas Todorov Date: Mon, 16 Dec 2024 20:25:12 +0200 Subject: [PATCH] fix name arg --- starlark/ucp_provider.go | 2 +- starlark/use.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/starlark/ucp_provider.go b/starlark/ucp_provider.go index d842332..f539911 100644 --- a/starlark/ucp_provider.go +++ b/starlark/ucp_provider.go @@ -90,7 +90,7 @@ func UcpProviderFn(thread *starlark.Thread, _ *starlark.Builtin, args starlark.T log.Fatalf("Failed to load kubeconfig: %v", err) } - switchWorkspace := NewUseWorkspaceCommand(config, mgmtKubeConfigPath) + switchWorkspace := NewUseWorkspaceCommand(workspace, config, mgmtKubeConfigPath) err = switchWorkspace.Run(context.Background()) if err != nil { return nil, err diff --git a/starlark/use.go b/starlark/use.go index cf90ba2..7c05c38 100644 --- a/starlark/use.go +++ b/starlark/use.go @@ -32,7 +32,7 @@ type UseWorkspaceCommand struct { } // NewUseWorkspaceCommand returns a new UseWorkspaceCommand. -func NewUseWorkspaceCommand(kubeConfig *clientcmdapi.Config, kubeconfigPath string) *UseWorkspaceCommand { +func NewUseWorkspaceCommand(workspace string, kubeConfig *clientcmdapi.Config, kubeconfigPath string) *UseWorkspaceCommand { kcpConfig, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig( &clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfigPath}, &clientcmd.ConfigOverrides{}, @@ -50,6 +50,7 @@ func NewUseWorkspaceCommand(kubeConfig *clientcmdapi.Config, kubeconfigPath stri kubeconfigPath: kubeconfigPath, adminUcpConfig: kubeConfig, kcpclient: kcpClient, + Name: workspace, modifyConfig: func(newConfig *clientcmdapi.Config, kubeconfigPath string) error { err := clientcmd.WriteToFile(*newConfig, kubeconfigPath) @@ -75,7 +76,7 @@ func (o *UseWorkspaceCommand) Run(ctx context.Context) (err error) { if name[0] == ':' { name = strings.TrimPrefix(name, ":") } else { - name = cluster.Server + ":space-1" + name = cluster.Server + ":" + name } // remove . and ..