Skip to content

Commit

Permalink
Merge pull request #11150 from liggitt/deprecate-whoami-token
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Sep 30, 2016
2 parents dfab2c1 + 2587916 commit 25aad16
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 24 deletions.
8 changes: 4 additions & 4 deletions contrib/completions/bash/oc
Original file line number Diff line number Diff line change
Expand Up @@ -13712,12 +13712,12 @@ _oc_whoami()
flags_with_completion=()
flags_completion=()

flags+=("--context")
flags+=("--show-context")
flags+=("-c")
local_nonpersistent_flags+=("--context")
flags+=("--token")
local_nonpersistent_flags+=("--show-context")
flags+=("--show-token")
flags+=("-t")
local_nonpersistent_flags+=("--token")
local_nonpersistent_flags+=("--show-token")
flags+=("--as=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
Expand Down
8 changes: 4 additions & 4 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -18264,12 +18264,12 @@ _openshift_cli_whoami()
flags_with_completion=()
flags_completion=()

flags+=("--context")
flags+=("--show-context")
flags+=("-c")
local_nonpersistent_flags+=("--context")
flags+=("--token")
local_nonpersistent_flags+=("--show-context")
flags+=("--show-token")
flags+=("-t")
local_nonpersistent_flags+=("--token")
local_nonpersistent_flags+=("--show-token")
flags+=("--as=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
Expand Down
8 changes: 4 additions & 4 deletions contrib/completions/zsh/oc
Original file line number Diff line number Diff line change
Expand Up @@ -13873,12 +13873,12 @@ _oc_whoami()
flags_with_completion=()
flags_completion=()

flags+=("--context")
flags+=("--show-context")
flags+=("-c")
local_nonpersistent_flags+=("--context")
flags+=("--token")
local_nonpersistent_flags+=("--show-context")
flags+=("--show-token")
flags+=("-t")
local_nonpersistent_flags+=("--token")
local_nonpersistent_flags+=("--show-token")
flags+=("--as=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
Expand Down
8 changes: 4 additions & 4 deletions contrib/completions/zsh/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -18425,12 +18425,12 @@ _openshift_cli_whoami()
flags_with_completion=()
flags_completion=()

flags+=("--context")
flags+=("--show-context")
flags+=("-c")
local_nonpersistent_flags+=("--context")
flags+=("--token")
local_nonpersistent_flags+=("--show-context")
flags+=("--show-token")
flags+=("-t")
local_nonpersistent_flags+=("--token")
local_nonpersistent_flags+=("--show-token")
flags+=("--as=")
flags+=("--certificate-authority=")
flags_with_completion+=("--certificate-authority")
Expand Down
4 changes: 2 additions & 2 deletions docs/man/man1/oc-whoami.1
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ user context.

.SH OPTIONS
.PP
\fB\-c\fP, \fB\-\-context\fP=false
\fB\-c\fP, \fB\-\-show\-context\fP=false
Print the current user context name

.PP
\fB\-t\fP, \fB\-\-token\fP=false
\fB\-t\fP, \fB\-\-show\-token\fP=false
Print the token the current session is using. This will return an error if you are using a different form of authentication.


Expand Down
4 changes: 2 additions & 2 deletions docs/man/man1/openshift-cli-whoami.1
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ user context.

.SH OPTIONS
.PP
\fB\-c\fP, \fB\-\-context\fP=false
\fB\-c\fP, \fB\-\-show\-context\fP=false
Print the current user context name

.PP
\fB\-t\fP, \fB\-\-token\fP=false
\fB\-t\fP, \fB\-\-show\-token\fP=false
Print the token the current session is using. This will return an error if you are using a different form of authentication.


Expand Down
18 changes: 14 additions & 4 deletions pkg/cmd/cli/cmd/whoami.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,18 @@ func NewCmdWhoAmI(name, fullName string, f *clientcmd.Factory, out io.Writer) *c
kcmdutil.CheckErr(err)
},
}
cmd.Flags().BoolP("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("context", "c", false, "Print the current user context name")

// Deprecated in 1.4
// Remove in 1.5 so we can use --token and --context for building the client again
cmd.Flags().Bool("token", false, "Deprecated, use --show-token instead")
cmd.Flags().Bool("context", false, "Deprecated, use --show-context instead")
cmd.Flags().MarkDeprecated("token", "use -t or --show-token instead")
cmd.Flags().MarkDeprecated("context", "use -c or --show-context instead")
cmd.Flags().MarkHidden("token")
cmd.Flags().MarkHidden("context")

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

return cmd
}
Expand All @@ -57,7 +67,7 @@ func (o WhoAmIOptions) WhoAmI() (*userapi.User, error) {
}

func RunWhoAmI(f *clientcmd.Factory, out io.Writer, cmd *cobra.Command, args []string, o *WhoAmIOptions) error {
if kcmdutil.GetFlagBool(cmd, "token") {
if kcmdutil.GetFlagBool(cmd, "token") || kcmdutil.GetFlagBool(cmd, "show-token") {
cfg, err := f.OpenShiftClientConfig.ClientConfig()
if err != nil {
return err
Expand All @@ -68,7 +78,7 @@ func RunWhoAmI(f *clientcmd.Factory, out io.Writer, cmd *cobra.Command, args []s
fmt.Fprintf(out, "%s\n", cfg.BearerToken)
return nil
}
if kcmdutil.GetFlagBool(cmd, "context") {
if kcmdutil.GetFlagBool(cmd, "context") || kcmdutil.GetFlagBool(cmd, "show-context") {
cfg, err := f.OpenShiftClientConfig.RawConfig()
if err != nil {
return err
Expand Down

0 comments on commit 25aad16

Please sign in to comment.