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

Add separate "projects" cmd to list all projects #9199

Merged

Conversation

juanvallejo
Copy link
Contributor

Fixes #8645

@@ -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"},
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor

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 :)

Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Member

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?.

@juanvallejo
Copy link
Contributor Author

juanvallejo commented Jun 7, 2016

While logged in as a test user:
oc login -u test -p test
oc projects

You are not a member of any projects. You can request a project to be created with the 'new-project' command.

oc new-project test
oc new-project test2

oc projects

Using project "test2" on server "https://10.0.2.15:8443".
Your projects are:
- test
* test2

@0xmichalis
Copy link
Contributor

Why do we need a separate command for this? Isn't oc get projects enough?

@juanvallejo
Copy link
Contributor Author

juanvallejo commented Jun 7, 2016

@Kargakis didn't know about oc get projects. oc projects does display the current project (and its server) as well. It could be a hybrid between oc project and oc get projects

@0xmichalis
Copy link
Contributor

@juanvallejo you should be able to add that info in the resource printer for projects and display anything additional in oc get projects.

@0xmichalis
Copy link
Contributor

0xmichalis commented Jun 7, 2016

Also tbh I don't mind breaking people who run oc projects. Upstream kubectl policy is not to use aliases and I think I agree with it. But I don't want a new command for it.

@fabianofranz
Copy link
Member

[test]

@juanvallejo
Copy link
Contributor Author

juanvallejo commented Jun 7, 2016

@fabianofranz or @deads2k Not sure if I can ask rosie-bot to re-test

@fabianofranz
Copy link
Member

re[test]


return nil
}
func (o ProjectsOptions) Validate() error {
Copy link
Member

Choose a reason for hiding this comment

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

This can be removed.

@fabianofranz
Copy link
Member

flake, [test] again

@juanvallejo
Copy link
Contributor Author

[test]

@juanvallejo juanvallejo force-pushed the jvallejo_add-projects-cmd branch from 0635d3a to c8080d0 Compare June 9, 2016 03:59
@juanvallejo
Copy link
Contributor Author

re[test]

"fmt"
"io"

// kapi "k8s.io/kubernetes/pkg/api"
Copy link
Member

Choose a reason for hiding this comment

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

delete if not needed.

@fabianofranz
Copy link
Member

@juanvallejo Minor comments, please address then LGTM.

type ProjectsOptions struct {
Config clientcmdapi.Config
ClientConfig *restclient.Config
ClientFn func() (*client.Client, error)
Copy link
Contributor

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

@juanvallejo juanvallejo force-pushed the jvallejo_add-projects-cmd branch from d8485e4 to 8f9bfd9 Compare June 13, 2016 21:34
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]))
Copy link
Member

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.

@fabianofranz
Copy link
Member

@juanvallejo added one minor comment, let me know when it's done. ;)

@juanvallejo juanvallejo force-pushed the jvallejo_add-projects-cmd branch from 8f9bfd9 to 4367497 Compare June 14, 2016 14:41
@juanvallejo
Copy link
Contributor Author

@fabianofranz Thanks for the feedback, I have updated the output according to your comment

@openshift-bot
Copy link
Contributor

openshift-bot commented Jun 14, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/4873/) (Image: devenv-rhel7_4377)

@juanvallejo juanvallejo force-pushed the jvallejo_add-projects-cmd branch from 4367497 to 9603c66 Compare June 14, 2016 16:17
@juanvallejo
Copy link
Contributor Author

re[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 9603c66

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/4840/)

@juanvallejo
Copy link
Contributor Author

[merge]

1 similar comment
@fabianofranz
Copy link
Member

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 9603c66

@openshift-bot openshift-bot merged commit 6ab98bc into openshift:master Jun 15, 2016
@deads2k
Copy link
Contributor

deads2k commented Jun 15, 2016

[merge]

@juanvallejo nice try :)

@juanvallejo juanvallejo deleted the jvallejo_add-projects-cmd branch June 15, 2016 14:41
@0xmichalis
Copy link
Contributor

@fabianofranz can we highlight the current project either by a different color or by using only one star instead of using (current)?

@juanvallejo
Copy link
Contributor Author

@Kargakis

can we highlight the current project either by a different color or by using only one star instead of using (current)

I like this suggestion, see #9439, it displays the current project (in a list of two or more) with bold green font and an asterisk in front.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants