From 4245d9e7b5b8ea28e4a11e01dbc57318c0906610 Mon Sep 17 00:00:00 2001 From: pacoxu Date: Mon, 1 Mar 2021 12:04:29 +0800 Subject: [PATCH] print log for default container of kubectl Kubernetes-commit: 96f8d6262459e802510244d2880886f8b481ee0e --- pkg/cmd/util/helpers.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/cmd/util/helpers.go b/pkg/cmd/util/helpers.go index b7d056a0..a4a75fef 100644 --- a/pkg/cmd/util/helpers.go +++ b/pkg/cmd/util/helpers.go @@ -756,6 +756,7 @@ func GetDefaultContainerName(pod *corev1.Pod, enableSuggestedCmdUsage bool, w io if annotations := pod.Annotations; annotations != nil && len(annotations[podutils.DefaultContainerAnnotationName]) > 0 { containerName := annotations[podutils.DefaultContainerAnnotationName] if exists, _ := podutils.FindContainerByName(pod, containerName); exists != nil { + fmt.Fprintf(w, "Defaulting container name to container %s.\n", containerName) return containerName } else { fmt.Fprintf(w, "Default container name %q in annotation not found in a pod\n", containerName)