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 option to oc whoami that prints server url #11180

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Sep 30, 2016

Fixes #11148

Currently there is no "simple" way to obtain the rest api's URL.
This patch adds an option --show-server || -u to oc whoami
that retrieves the server url from the first cluster in config.Cluster

Before

$ oc config view --minify -o jsonpath='{.clusters[*].cluster.server}'
https://10.13.137.149:8443% # no linebreak at the end

After

$ oc whoami -u # or --show-server
https://10.13.137.149:8443

cc @openshift/cli-review @smarterclayton

@liggitt
Copy link
Contributor

liggitt commented Sep 30, 2016

--show-server to parallel the other options?

@liggitt
Copy link
Contributor

liggitt commented Sep 30, 2016

Not sure a short flag is needed

@juanvallejo
Copy link
Contributor Author

@liggitt Thanks for the feedback, comments addressed 85e2d6b

Copy link
Member

@fabianofranz fabianofranz left a comment

Choose a reason for hiding this comment

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

nits otherwise lgtm.

@@ -53,6 +53,7 @@ func NewCmdWhoAmI(name, fullName string, f *clientcmd.Factory, out io.Writer) *c

cmd.Flags().BoolP("show-token", "t", false, "Print the token the current session is using. This will return an error if you are using a different form of authentication.")
cmd.Flags().BoolP("show-context", "c", false, "Print the current user context name")
cmd.Flags().Bool("show-server", false, "Print the server's REST API URL")
Copy link
Member

Choose a reason for hiding this comment

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

"Print the current server's REST API URL"

fmt.Fprintf(out, "%s\n", c.Server)
return nil
}
return fmt.Errorf("unable to get clusters. Cannot retrieve server url")
Copy link
Member

Choose a reason for hiding this comment

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

"unable to get clusters. Cannot retrieve server URL."

Fixes openshift#11148

Currently there is no "simple" way to obtain the rest api's URL.
This patch adds an option `--show-server-url` || `-u` to `oc whoami`
that retrieves the server url from the first cluster in `config.Cluster`

**Before**

```
$ oc config view --minify -o jsonpath='{.clusters[*].cluster.server}'
https://10.13.137.149:8443% # no linebreak at the end
```

**After**

```
$ oc whoami -u # or --show-server-url
https://10.13.137.149:8443
```
@juanvallejo juanvallejo force-pushed the jvallejo/add-means-of-getting-url-rest-api branch from 1b06647 to 341f89a Compare October 3, 2016 17:49
@juanvallejo
Copy link
Contributor Author

@fabianofranz thanks for the feedback! Review comments addressed, went ahead and squashed

@fabianofranz
Copy link
Member

LGTM [merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 341f89a

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 341f89a

@openshift-bot
Copy link
Contributor

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

@juanvallejo
Copy link
Contributor Author

@openshift-bot
Copy link
Contributor

openshift-bot commented Oct 4, 2016

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

@openshift-bot openshift-bot merged commit 02751ff into openshift:master Oct 4, 2016
@juanvallejo juanvallejo deleted the jvallejo/add-means-of-getting-url-rest-api branch October 4, 2016 13:22
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.

4 participants