mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +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")
|
||||
}
|
||||
|
||||
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]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user