Updates kubectl log cmd per PR feedback

This commit is contained in:
Dylan Carney 2014-12-11 17:40:47 -08:00
parent 3f88f27d7b
commit ba5c18816e

View File

@ -32,6 +32,10 @@ func (f *Factory) NewCmdLog(out io.Writer) *cobra.Command {
usageError(cmd, "<pod> is required for log")
}
if len(args) > 2 {
usageError(cmd, "log <pod> [<container>]")
}
namespace := GetKubeNamespace(cmd)
client, err := f.ClientBuilder.Client()
checkErr(err)
@ -43,12 +47,12 @@ func (f *Factory) NewCmdLog(out io.Writer) *cobra.Command {
var container string
if len(args) == 1 {
if len(pod.Spec.Containers) == 1 {
// Get logs for the only container in the pod
container = pod.Spec.Containers[0].Name
} else {
if len(pod.Spec.Containers) != 1 {
usageError(cmd, "<container> is required for pods with multiple containers")
}
// Get logs for the only container in the pod
container = pod.Spec.Containers[0].Name
} else {
container = args[1]
}