Skip to content

Print clearer messages in oc status when user has no projects #12304

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

Conversation

juanvallejo
Copy link
Contributor

Related bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1405636

This patch re-uses the "No projects" message from oc login in oc status if a user attempts to use the command without first creating any
projects. This message suggests to the user a way to request a new
project rather than returning an error to the user which warns that they
cannot "get" projects in project "default".

Before

$ oc login -u newuser -p any
Login successful.

You don't have any projects. You can try to create a new project, by
running

    oc new-project <projectname>

$ oc status
Error from server: User "newuser" cannot get projects in project
"default"

After

$ oc login -u newuser -p any
Login successful.

You don't have any projects. You can try to create a new project, by
running

    oc new-project <projectname>

$ oc status
You don't have any projects. You can try to create a new project, by
running

    oc new-project <projectname>

Additionally, since the same message from oc login is re-used, if a
user does not have access to request new projects, the following message
is printed instead:

$ oc status
You don't have any projects. Contact your system administrator to
request a project.

@openshift/cli-review

"github.com/openshift/origin/pkg/client"
)

func CanRequestProjects(config *restclient.Config, defaultNamespace string) (bool, error) {
Copy link
Contributor Author

@juanvallejo juanvallejo Dec 19, 2016

Choose a reason for hiding this comment

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

@fabianofranz The reason why I created a new file under a new package pkg/cmd/cli/cmd/login/util rather than placing this helper under pkg/cmd/cli/cmd/login/helpers.go was because I would introduce a dependency cycle by importing the login package in pkg/cmd/cli/describe/projectstatus.go

@juanvallejo
Copy link
Contributor Author

[test]

@juanvallejo juanvallejo changed the title Print more clear message in oc status when user has no projects Print clearer messages in oc status when user has no projects Dec 19, 2016
@fabianofranz
Copy link
Member

LGTM, please squash. ;)

This patch re-uses the "No projects" message from `oc login` in `oc
status` if a user attempts to use the command without first creating any
projects. This message suggests to the user a way to request a new
project rather than returning an error to the user which warns that they
cannot "get" projects in project "default".

**Before**

```
$ oc login -u newuser -p any
Login successful.

You don't have any projects. You can try to create a new project, by
running

    oc new-project <projectname>

$ oc status
Error from server: User "newuser" cannot get projects in project
"default"
```

**After**

```
$ oc login -u newuser -p any
Login successful.

You don't have any projects. You can try to create a new project, by
running

    oc new-project <projectname>

$ oc status
You don't have any projects. You can try to create a new project, by
running

    oc new-project <projectname>

```

Additionally, since the same message from `oc login` is re-used, if a
user does not have access to request new projects, the following message
is printed instead:

```
$ oc status
You don't have any projects. Contact your system administrator to
request a project.
```
@juanvallejo juanvallejo force-pushed the jvallejo/non-error-output-in-oc-status branch from cef50e1 to 44bfec9 Compare December 21, 2016 14:42
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 44bfec9

@juanvallejo
Copy link
Contributor Author

@fabianofranz Thanks! Done

@fabianofranz
Copy link
Member

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 44bfec9

@openshift-bot
Copy link
Contributor

openshift-bot commented Dec 21, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12568/) (Base Commit: 3164ce5) (Image: devenv-rhel7_5584)

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test ABORTED (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12564/) (Base Commit: 2dd7247)

@openshift-bot openshift-bot merged commit 1134ff1 into openshift:master Dec 21, 2016
@juanvallejo juanvallejo deleted the jvallejo/non-error-output-in-oc-status branch December 21, 2016 18:41
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.

3 participants