mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Updates kubectl log cmd per PR feedback
This commit is contained in:
parent
3f88f27d7b
commit
ba5c18816e
@ -32,6 +32,10 @@ func (f *Factory) NewCmdLog(out io.Writer) *cobra.Command {
|
|||||||
usageError(cmd, "<pod> is required for log")
|
usageError(cmd, "<pod> is required for log")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(args) > 2 {
|
||||||
|
usageError(cmd, "log <pod> [<container>]")
|
||||||
|
}
|
||||||
|
|
||||||
namespace := GetKubeNamespace(cmd)
|
namespace := GetKubeNamespace(cmd)
|
||||||
client, err := f.ClientBuilder.Client()
|
client, err := f.ClientBuilder.Client()
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
@ -43,12 +47,12 @@ func (f *Factory) NewCmdLog(out io.Writer) *cobra.Command {
|
|||||||
|
|
||||||
var container string
|
var container string
|
||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
if len(pod.Spec.Containers) == 1 {
|
if len(pod.Spec.Containers) != 1 {
|
||||||
// Get logs for the only container in the pod
|
|
||||||
container = pod.Spec.Containers[0].Name
|
|
||||||
} else {
|
|
||||||
usageError(cmd, "<container> is required for pods with multiple containers")
|
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 {
|
} else {
|
||||||
container = args[1]
|
container = args[1]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user