Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/lk/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,5 @@ func setDefaultProject(ctx context.Context, cmd *cli.Command) error {
return nil
}

return errors.New("project not found")
return config.ProjectNotFoundError(cliConfig.Projects)
}
15 changes: 13 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func LoadProjectBySubdomain(subdomain string) (*ProjectConfig, error) {
}
}

return nil, errors.New("project not found")
return nil, ProjectNotFoundError(conf.Projects)
}

func LoadProject(name string) (*ProjectConfig, error) {
Expand All @@ -92,7 +92,18 @@ func LoadProject(name string) (*ProjectConfig, error) {
}
}

return nil, errors.New("project not found")
return nil, ProjectNotFoundError(conf.Projects)
}

func ProjectNotFoundError(projects []ProjectConfig) error {
if len(projects) == 0 {
return errors.New("project not found. No projects configured, use `lk cloud auth` or `lk project add` to add a new project")
}
names := make([]string, len(projects))
for i, p := range projects {
names[i] = p.Name
}
return fmt.Errorf("project not found. Available projects: %s", strings.Join(names, ", "))
}

// LoadOrCreate loads config file from ~/.livekit/cli-config.yaml
Expand Down
Loading