From ea6dca580ff84459ec02dd191c8e75fd00761364 Mon Sep 17 00:00:00 2001 From: Jake Malachowski <5766239+jakemalachowski@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:23:33 -0800 Subject: [PATCH] Update recommended action in workspace error (#134) --- pkg/config/config.go | 6 ++++-- pkg/validate/workspace.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 2d627d4..1e09735 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -15,6 +15,8 @@ var defaultConfigPath string const configPathEnvKey = "RENDER_CLI_CONFIG_PATH" const workspaceEnvKey = "RENDER_WORKSPACE" +var ErrNoWorkspace = errors.New("no workspace set. Use `render workspace set` to set a workspace") + type Config struct { Version int `yaml:"version"` Workspace string `yaml:"workspace"` @@ -66,7 +68,7 @@ func WorkspaceID() (string, error) { return "", err } if cfg.Workspace == "" { - return "", errors.New("no workspace set. Use `render workspace` to set a workspace") + return "", ErrNoWorkspace } return cfg.Workspace, nil } @@ -81,7 +83,7 @@ func WorkspaceName() (string, error) { return "", err } if cfg.WorkspaceName == "" { - return "", errors.New("no workspace set. Use `render workspace` to set a workspace") + return "", ErrNoWorkspace } return cfg.WorkspaceName, nil } diff --git a/pkg/validate/workspace.go b/pkg/validate/workspace.go index 77f6bd2..4c58123 100644 --- a/pkg/validate/workspace.go +++ b/pkg/validate/workspace.go @@ -14,7 +14,7 @@ func WorkspaceMatches(workspaceID string) error { return err } if cfg.Workspace != "" && cfg.Workspace != workspaceID { - return fmt.Errorf("resource in workspace %s does not match the workspace in the current workspace context %s. Run `render workspace` to change contexts", workspaceID, cfg.Workspace) + return fmt.Errorf("resource in workspace does not match the workspace in the current workspace context %s. Run `render workspace set %s` to change contexts", cfg.Workspace, workspaceID) } return nil }