-
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 option to oc whoami
that prints server url
#11180
add option to oc whoami
that prints server url
#11180
Conversation
--show-server to parallel the other options? |
Not sure a short flag is needed |
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.
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") |
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.
"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") |
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.
"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 ```
1b06647
to
341f89a
Compare
@fabianofranz thanks for the feedback! Review comments addressed, went ahead and squashed |
LGTM [merge] |
Evaluated for origin merge up to 341f89a |
[Test]ing while waiting on the merge queue |
Evaluated for origin test up to 341f89a |
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/9587/) |
merge tests flaked on AWS failure: https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_check/6660/consoleFull#-27859736956a6674fe4b089752bb4314c |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/9602/) (Image: devenv-rhel7_5126) |
Fixes #11148
Currently there is no "simple" way to obtain the rest api's URL.
This patch adds an option
--show-server
||-u
tooc whoami
that retrieves the server url from the first cluster in
config.Cluster
Before
After
cc @openshift/cli-review @smarterclayton