Skip to content

Commit

Permalink
fix name arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Atanas Todorov committed Dec 16, 2024
1 parent b81353c commit 188bd3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion starlark/ucp_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions starlark/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand All @@ -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)
Expand All @@ -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 ..
Expand Down

0 comments on commit 188bd3a

Please sign in to comment.