Fix panic when the namespace flag is not present

This commit is contained in:
Michal Fojtik 2016-05-23 16:41:31 +02:00
parent 952e8302fb
commit f79998a9b1

View File

@ -235,6 +235,7 @@ Find more information at https://github.com/kubernetes/kubernetes.`,
cmds.AddCommand(NewCmdExplain(f, out))
cmds.AddCommand(NewCmdConvert(f, out))
if cmds.Flag("namespace") != nil {
if cmds.Flag("namespace").Annotations == nil {
cmds.Flag("namespace").Annotations = map[string][]string{}
}
@ -242,6 +243,7 @@ Find more information at https://github.com/kubernetes/kubernetes.`,
cmds.Flag("namespace").Annotations[cobra.BashCompCustom],
"__kubectl_get_namespaces",
)
}
return cmds
}