Browse code

Favor --show-token over --token for whoami

Jordan Liggitt authored on 2016/09/29 11:41:00
Showing 7 changed files
... ...
@@ -13712,12 +13712,12 @@ _oc_whoami()
13712 13712
     flags_with_completion=()
13713 13713
     flags_completion=()
13714 13714
 
13715
-    flags+=("--context")
13715
+    flags+=("--show-context")
13716 13716
     flags+=("-c")
13717
-    local_nonpersistent_flags+=("--context")
13718
-    flags+=("--token")
13717
+    local_nonpersistent_flags+=("--show-context")
13718
+    flags+=("--show-token")
13719 13719
     flags+=("-t")
13720
-    local_nonpersistent_flags+=("--token")
13720
+    local_nonpersistent_flags+=("--show-token")
13721 13721
     flags+=("--as=")
13722 13722
     flags+=("--certificate-authority=")
13723 13723
     flags_with_completion+=("--certificate-authority")
... ...
@@ -18264,12 +18264,12 @@ _openshift_cli_whoami()
18264 18264
     flags_with_completion=()
18265 18265
     flags_completion=()
18266 18266
 
18267
-    flags+=("--context")
18267
+    flags+=("--show-context")
18268 18268
     flags+=("-c")
18269
-    local_nonpersistent_flags+=("--context")
18270
-    flags+=("--token")
18269
+    local_nonpersistent_flags+=("--show-context")
18270
+    flags+=("--show-token")
18271 18271
     flags+=("-t")
18272
-    local_nonpersistent_flags+=("--token")
18272
+    local_nonpersistent_flags+=("--show-token")
18273 18273
     flags+=("--as=")
18274 18274
     flags+=("--certificate-authority=")
18275 18275
     flags_with_completion+=("--certificate-authority")
... ...
@@ -13873,12 +13873,12 @@ _oc_whoami()
13873 13873
     flags_with_completion=()
13874 13874
     flags_completion=()
13875 13875
 
13876
-    flags+=("--context")
13876
+    flags+=("--show-context")
13877 13877
     flags+=("-c")
13878
-    local_nonpersistent_flags+=("--context")
13879
-    flags+=("--token")
13878
+    local_nonpersistent_flags+=("--show-context")
13879
+    flags+=("--show-token")
13880 13880
     flags+=("-t")
13881
-    local_nonpersistent_flags+=("--token")
13881
+    local_nonpersistent_flags+=("--show-token")
13882 13882
     flags+=("--as=")
13883 13883
     flags+=("--certificate-authority=")
13884 13884
     flags_with_completion+=("--certificate-authority")
... ...
@@ -18425,12 +18425,12 @@ _openshift_cli_whoami()
18425 18425
     flags_with_completion=()
18426 18426
     flags_completion=()
18427 18427
 
18428
-    flags+=("--context")
18428
+    flags+=("--show-context")
18429 18429
     flags+=("-c")
18430
-    local_nonpersistent_flags+=("--context")
18431
-    flags+=("--token")
18430
+    local_nonpersistent_flags+=("--show-context")
18431
+    flags+=("--show-token")
18432 18432
     flags+=("-t")
18433
-    local_nonpersistent_flags+=("--token")
18433
+    local_nonpersistent_flags+=("--show-token")
18434 18434
     flags+=("--as=")
18435 18435
     flags+=("--certificate-authority=")
18436 18436
     flags_with_completion+=("--certificate-authority")
... ...
@@ -23,11 +23,11 @@ user context.
23 23
 
24 24
 .SH OPTIONS
25 25
 .PP
26
-\fB\-c\fP, \fB\-\-context\fP=false
26
+\fB\-c\fP, \fB\-\-show\-context\fP=false
27 27
     Print the current user context name
28 28
 
29 29
 .PP
30
-\fB\-t\fP, \fB\-\-token\fP=false
30
+\fB\-t\fP, \fB\-\-show\-token\fP=false
31 31
     Print the token the current session is using. This will return an error if you are using a different form of authentication.
32 32
 
33 33
 
... ...
@@ -23,11 +23,11 @@ user context.
23 23
 
24 24
 .SH OPTIONS
25 25
 .PP
26
-\fB\-c\fP, \fB\-\-context\fP=false
26
+\fB\-c\fP, \fB\-\-show\-context\fP=false
27 27
     Print the current user context name
28 28
 
29 29
 .PP
30
-\fB\-t\fP, \fB\-\-token\fP=false
30
+\fB\-t\fP, \fB\-\-show\-token\fP=false
31 31
     Print the token the current session is using. This will return an error if you are using a different form of authentication.
32 32
 
33 33
 
... ...
@@ -41,8 +41,18 @@ func NewCmdWhoAmI(name, fullName string, f *clientcmd.Factory, out io.Writer) *c
41 41
 			kcmdutil.CheckErr(err)
42 42
 		},
43 43
 	}
44
-	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.")
45
-	cmd.Flags().BoolP("context", "c", false, "Print the current user context name")
44
+
45
+	// Deprecated in 1.4
46
+	// Remove in 1.5 so we can use --token and --context for building the client again
47
+	cmd.Flags().Bool("token", false, "Deprecated, use --show-token instead")
48
+	cmd.Flags().Bool("context", false, "Deprecated, use --show-context instead")
49
+	cmd.Flags().MarkDeprecated("token", "use -t or --show-token instead")
50
+	cmd.Flags().MarkDeprecated("context", "use -c or --show-context instead")
51
+	cmd.Flags().MarkHidden("token")
52
+	cmd.Flags().MarkHidden("context")
53
+
54
+	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.")
55
+	cmd.Flags().BoolP("show-context", "c", false, "Print the current user context name")
46 56
 
47 57
 	return cmd
48 58
 }
... ...
@@ -57,7 +67,7 @@ func (o WhoAmIOptions) WhoAmI() (*userapi.User, error) {
57 57
 }
58 58
 
59 59
 func RunWhoAmI(f *clientcmd.Factory, out io.Writer, cmd *cobra.Command, args []string, o *WhoAmIOptions) error {
60
-	if kcmdutil.GetFlagBool(cmd, "token") {
60
+	if kcmdutil.GetFlagBool(cmd, "token") || kcmdutil.GetFlagBool(cmd, "show-token") {
61 61
 		cfg, err := f.OpenShiftClientConfig.ClientConfig()
62 62
 		if err != nil {
63 63
 			return err
... ...
@@ -68,7 +78,7 @@ func RunWhoAmI(f *clientcmd.Factory, out io.Writer, cmd *cobra.Command, args []s
68 68
 		fmt.Fprintf(out, "%s\n", cfg.BearerToken)
69 69
 		return nil
70 70
 	}
71
-	if kcmdutil.GetFlagBool(cmd, "context") {
71
+	if kcmdutil.GetFlagBool(cmd, "context") || kcmdutil.GetFlagBool(cmd, "show-context") {
72 72
 		cfg, err := f.OpenShiftClientConfig.RawConfig()
73 73
 		if err != nil {
74 74
 			return err