Fix kubectl get error when both all-namespaces and namespace are provided.

As per kubectl get help, --namespace should be ignored with all-namespaces,
but kubectl get pods --all-namespaces --namespace=<name-space> gives
following error:

"the namespace from the provided object "default" does not match the
namespace "". You must pass '--namespace=default' to perform this
operation."

This commit fixes this error issue.
This commit is contained in:
Avesh Agarwal
2016-02-08 02:47:20 -05:00
parent 1c6a223eaa
commit c0e1623be2
2 changed files with 31 additions and 0 deletions

View File

@@ -119,6 +119,10 @@ func RunGet(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
return err
}
if allNamespaces {
enforceNamespace = false
}
if len(args) == 0 && len(options.Filenames) == 0 {
fmt.Fprint(out, "You must specify the type of resource to get. ", valid_resources)
return cmdutil.UsageError(cmd, "Required resource not specified.")