Merge pull request #99615 from pacoxu/default-container/exec

kubectl: print info for default container annotation usage
This commit is contained in:
Kubernetes Prow Robot 2021-03-02 12:16:18 -08:00 committed by GitHub
commit 2a33b8293a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)