Skip to content

Commit da86116

Browse files
Merge pull request #18706 from Oats87/surpress-over-50
Automatic merge from submit-queue. Surpress project list on login if you have access to greater than 50 projects As a compromise to #18684 we are going to surpress the project list functionality if the number of projects available to a user is greater than 50 Original RFE was at BZ #1542326 - https://bugzilla.redhat.com/show_bug.cgi?id=1542326 RFE is within that BZ, but there was a compromise.
2 parents cb04215 + 8125376 commit da86116

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

pkg/oc/cli/cmd/login/loginoptions.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import (
3434

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

37+
const projectsItemsSuppressThreshold = 50
38+
3739
// LoginOptions is a helper for the login and setup process, gathers all information required for a
3840
// successful login and eventual update of config files.
3941
// Depending on the Reader present it can be interactive, asking for terminal input in
@@ -317,15 +319,20 @@ func (o *LoginOptions) gatherProjectInfo() error {
317319
}
318320
o.Project = current.Name
319321

320-
fmt.Fprintf(o.Out, "You have access to the following projects and can switch between them with '%s project <projectname>':\n\n", o.CommandName)
321-
for _, p := range projects.List() {
322-
if o.Project == p {
323-
fmt.Fprintf(o.Out, " * %s\n", p)
324-
} else {
325-
fmt.Fprintf(o.Out, " %s\n", p)
322+
// 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
323+
if len(projectsItems) > projectsItemsSuppressThreshold {
324+
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)
325+
} else {
326+
fmt.Fprintf(o.Out, "You have access to the following projects and can switch between them with '%s project <projectname>':\n\n", o.CommandName)
327+
for _, p := range projects.List() {
328+
if o.Project == p {
329+
fmt.Fprintf(o.Out, " * %s\n", p)
330+
} else {
331+
fmt.Fprintf(o.Out, " %s\n", p)
332+
}
326333
}
334+
fmt.Fprintln(o.Out)
327335
}
328-
fmt.Fprintln(o.Out)
329336
fmt.Fprintf(o.Out, "Using project %q.\n", o.Project)
330337
}
331338

0 commit comments

Comments
 (0)