Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surpress project list on login if you have access to greater than 50 projects #18706

Merged
merged 1 commit into from
Feb 22, 2018
Merged
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
21 changes: 14 additions & 7 deletions pkg/oc/cli/cmd/login/loginoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (

const defaultClusterURL = "https://localhost:8443"

const projectsItemsSuppressThreshold = 50

// LoginOptions is a helper for the login and setup process, gathers all information required for a
// successful login and eventual update of config files.
// Depending on the Reader present it can be interactive, asking for terminal input in
Expand Down Expand Up @@ -317,15 +319,20 @@ func (o *LoginOptions) gatherProjectInfo() error {
}
o.Project = current.Name

fmt.Fprintf(o.Out, "You have access to the following projects and can switch between them with '%s project <projectname>':\n\n", o.CommandName)
for _, p := range projects.List() {
if o.Project == p {
fmt.Fprintf(o.Out, " * %s\n", p)
} else {
fmt.Fprintf(o.Out, " %s\n", p)
// Suppress project listing if the number of projects available to the user is greater than the threshold. Prevents unnecessarily noisy logins on clusters with large numbers of projects
if len(projectsItems) > projectsItemsSuppressThreshold {
fmt.Fprintf(o.Out, "You have access to %d projects, the list has been suppressed. You can list all projects with '%s projects'\n\n", len(projectsItems), o.CommandName)
} else {
fmt.Fprintf(o.Out, "You have access to the following projects and can switch between them with '%s project <projectname>':\n\n", o.CommandName)
for _, p := range projects.List() {
if o.Project == p {
fmt.Fprintf(o.Out, " * %s\n", p)
} else {
fmt.Fprintf(o.Out, " %s\n", p)
}
}
fmt.Fprintln(o.Out)
}
fmt.Fprintln(o.Out)
fmt.Fprintf(o.Out, "Using project %q.\n", o.Project)
}

Expand Down