-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add separate "projects" cmd to list all projects #9199
Add separate "projects" cmd to list all projects #9199
Conversation
@@ -66,7 +66,6 @@ func NewCmdProject(fullName string, f *clientcmd.Factory, out io.Writer) *cobra. | |||
Short: "Switch to another project", | |||
Long: projectLong, | |||
Example: fmt.Sprintf(projectExample, fullName), | |||
Aliases: []string{"projects"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this break existing uses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far, the only test against an oc projects
command was to make sure it returned the same --help
output as oc project
, I have updated this, but aside from running new and existing tests on it, I haven't found any conflicts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alias. ouch.. yes it will
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean uses by the world at large, which we can't refactor :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean uses by the world at large, which we can't refactor :)
I suspect that @fabianofranz may take it anyway if he thinks its a usability gain. Realistically the exposure is small, non-scripts may expect this behavior anyway and oc project
was never something reason to script against.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with this being a breaking change given the gains. But I'd like to minimize the breakage by making the exact current message still present in the output message of both project
and projects
.
$ oc project
Using project "awesome" on server "https://127.0.0.1:8443".
$ oc projects
You have access to the following projects and can switch between them with 'oc project <projectname>':
* awesome (current)
* notsoawesome
* okone
* weirdo
Using project "awesome" on server "https://127.0.0.1:8443".
That's also consistent with how we print the projects after logging in, and printing the current one at the end should address the use cases of having a long list of projects.
Comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kargakis we consider ok to use aliases for things like plural/singular. But aliases should not be "smart" so for for anything other than that (e.g. remove/delete) we must use suggestions like in $ oc remove\n did you mean delete?
.
While logged in as a test user:
|
Why do we need a separate command for this? Isn't |
@Kargakis didn't know about |
@juanvallejo you should be able to add that info in the resource printer for projects and display anything additional in |
Also tbh I don't mind breaking people who run |
[test] |
@fabianofranz or @deads2k Not sure if I can ask rosie-bot to re-test |
re[test] |
|
||
return nil | ||
} | ||
func (o ProjectsOptions) Validate() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed.
flake, [test] again |
[test] |
0635d3a
to
c8080d0
Compare
re[test] |
"fmt" | ||
"io" | ||
|
||
// kapi "k8s.io/kubernetes/pkg/api" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete if not needed.
@juanvallejo Minor comments, please address then LGTM. |
type ProjectsOptions struct { | ||
Config clientcmdapi.Config | ||
ClientConfig *restclient.Config | ||
ClientFn func() (*client.Client, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a ProjectNamespacer instead of a callback
d8485e4
to
8f9bfd9
Compare
case 0: | ||
msg += "You are not a member of any projects. You can request a project to be created with the 'new-project' command." | ||
case 1: | ||
msg += fmt.Sprintf("\nYou have one project on this server: %s", api.DisplayNameAndNameForProject(&projects[0])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think \n
is not needed here, it would add a linebreak where other cases don't have it. Also, use %q
instead of %s
so that you have double quotes in the project name, and add a "." after it at the end of the phrase.
@juanvallejo added one minor comment, let me know when it's done. ;) |
8f9bfd9
to
4367497
Compare
@fabianofranz Thanks for the feedback, I have updated the output according to your comment |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/4873/) (Image: devenv-rhel7_4377) |
4367497
to
9603c66
Compare
re[test] |
Evaluated for origin test up to 9603c66 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/4840/) |
[merge] |
1 similar comment
[merge] |
Evaluated for origin merge up to 9603c66 |
@juanvallejo nice try :) |
@fabianofranz can we highlight the current project either by a different color or by using only one star instead of using |
Fixes #8645