Commit 8a7f8bc0 authored by Zhenguo Niu's avatar Zhenguo Niu

Move output and url checks under raw flag condition

parent a0a69a35
...@@ -212,7 +212,8 @@ func (options *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args ...@@ -212,7 +212,8 @@ func (options *GetOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
// Validate checks the set of flags provided by the user. // Validate checks the set of flags provided by the user.
func (options *GetOptions) Validate(cmd *cobra.Command) error { func (options *GetOptions) Validate(cmd *cobra.Command) error {
if len(options.Raw) > 0 && (options.Watch || options.WatchOnly || len(options.LabelSelector) > 0 || options.Export) { if len(options.Raw) > 0 {
if options.Watch || options.WatchOnly || len(options.LabelSelector) > 0 || options.Export {
return fmt.Errorf("--raw may not be specified with other flags that filter the server request or alter the output") return fmt.Errorf("--raw may not be specified with other flags that filter the server request or alter the output")
} }
if len(cmdutil.GetFlagString(cmd, "output")) > 0 { if len(cmdutil.GetFlagString(cmd, "output")) > 0 {
...@@ -221,6 +222,7 @@ func (options *GetOptions) Validate(cmd *cobra.Command) error { ...@@ -221,6 +222,7 @@ func (options *GetOptions) Validate(cmd *cobra.Command) error {
if _, err := url.ParseRequestURI(options.Raw); err != nil { if _, err := url.ParseRequestURI(options.Raw); err != nil {
return cmdutil.UsageErrorf(cmd, "--raw must be a valid URL path: %v", err) return cmdutil.UsageErrorf(cmd, "--raw must be a valid URL path: %v", err)
} }
}
if cmdutil.GetFlagBool(cmd, "show-labels") { if cmdutil.GetFlagBool(cmd, "show-labels") {
outputOption := cmd.Flags().Lookup("output").Value.String() outputOption := cmd.Flags().Lookup("output").Value.String()
if outputOption != "" && outputOption != "wide" { if outputOption != "" && outputOption != "wide" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment