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

Conversation

Oats87
Copy link
Contributor

@Oats87 Oats87 commented Feb 21, 2018

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.

@openshift-ci-robot openshift-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 21, 2018
fmt.Fprintf(o.Out, " * %s\n", p)
} else {
fmt.Fprintf(o.Out, " %s\n", p)
if len(projectsItems) > 50 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the 50 a constant maxProjectItemLimit (or a similar name) at the top of this file.

} else {
fmt.Fprintf(o.Out, " %s\n", p)
if len(projectsItems) > 50 {
fmt.Fprintf(o.Out, "You have access to %d projects, the list has been surpressed. You can list all projects with '%s projects'\n", len(projectsItems), o.CommandName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be worth adding a comment before this line, explaining why we are doing this. That way we can prevent someone in the future from accidentally reverting this

@juanvallejo
Copy link
Contributor

/lgtm
Minor comments, otherwise lgtm.

@enj for approval tag

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 21, 2018
@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 21, 2018
@enj
Copy link
Contributor

enj commented Feb 21, 2018

@Oats87 please squash into one commit and include the text Bug 1542326 in the commit message.


// Surpress 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) > projectsItemsSurpressThreshold {
fmt.Fprintf(o.Out, "You have access to %d projects, the list has been surpressed. You can list all projects with '%s projects'\n", len(projectsItems), o.CommandName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: have this end with two newlines to match:

normal user:

Login successful.

You have access to the following projects and can switch between them with 'oc project <projectname>':

    abb
    abbb
  * abbbb

Using project "abbbb".

admin:

Logged into "https://10.13.129.85:8443" as "system:admin" using existing credentials.

You have access to 123 projects, the list has been surpressed. You can list all projects with 'oc projects'
Using project "abbbb".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed that second newline while validating the Fprintf line with @juanvallejo ; should I add it back in?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@enj I initially saw that extra newline as part of the "padding" for a list of projects. Since we are not listing projects in that second example, I thought to omit it instead. I do not feel strongly about this one way or another

@Oats87 Oats87 force-pushed the surpress-over-50 branch 3 times, most recently from 769bdfd to 605d7bb Compare February 21, 2018 23:54
@enj
Copy link
Contributor

enj commented Feb 22, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 22, 2018
@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 22, 2018
@Oats87
Copy link
Contributor Author

Oats87 commented Feb 22, 2018

Sorry @enj @juanvallejo I had to push one last time because suppress was misspelled (once it was misspelled once, I took off running with it without batting an eye)

@enj
Copy link
Contributor

enj commented Feb 22, 2018

@Oats87 I don't we want that information in the commit message though 😄

@enj
Copy link
Contributor

enj commented Feb 22, 2018

@Oats87 also, you need to run hack/verify-gofmt.sh | xargs -n 1 gofmt -s -w

Added conditional to project list that will suppress project
list output on login if the list is greater than 50.

Bug 1542326
@Oats87
Copy link
Contributor Author

Oats87 commented Feb 22, 2018

@enj Haha, understood. I went ahead and pulled that line out.

Did you see a format error on the file? Thanks for the command, I didn't know about that.

When I ran it, it didn't say any files were not formatted correctly, and I diff'ed the loginoptions.go file between the output of gofmt -s and the existing file and there were no differences

@enj
Copy link
Contributor

enj commented Feb 22, 2018

/ok-to-test
/lgtm
/refresh

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 22, 2018
@openshift-ci-robot openshift-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 22, 2018
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enj, juanvallejo, Oats87

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue.

@openshift-merge-robot openshift-merge-robot merged commit da86116 into openshift:master Feb 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants