Merge pull request #26078 from mfojtik/fix-nil-annnotations

Automatic merge from submit-queue

Fix panic when the namespace flag is not present

We don't set the namespace in OpenShift, so we need to check if the namespace flag is present.
This commit is contained in:
k8s-merge-robot 2016-05-29 10:32:33 -07:00
commit 10b271c6de

View File

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