print log for default container of kubectl

Kubernetes-commit: 96f8d6262459e802510244d2880886f8b481ee0e
This commit is contained in:
pacoxu 2021-03-01 12:04:29 +08:00 committed by Kubernetes Publisher
parent 92a87bedd1
commit 4245d9e7b5
1 changed files with 1 additions and 0 deletions

View File

@ -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)