Skip to content

Commit

Permalink
Update recommended action in workspace error (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemalachowski authored Nov 18, 2024
1 parent cb243bc commit ea6dca5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/validate/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit ea6dca5

Please sign in to comment.