mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #99615 from pacoxu/default-container/exec
kubectl: print info for default container annotation usage
This commit is contained in:
commit
2a33b8293a
@ -756,6 +756,7 @@ func GetDefaultContainerName(pod *corev1.Pod, enableSuggestedCmdUsage bool, w io
|
|||||||
if annotations := pod.Annotations; annotations != nil && len(annotations[podutils.DefaultContainerAnnotationName]) > 0 {
|
if annotations := pod.Annotations; annotations != nil && len(annotations[podutils.DefaultContainerAnnotationName]) > 0 {
|
||||||
containerName := annotations[podutils.DefaultContainerAnnotationName]
|
containerName := annotations[podutils.DefaultContainerAnnotationName]
|
||||||
if exists, _ := podutils.FindContainerByName(pod, containerName); exists != nil {
|
if exists, _ := podutils.FindContainerByName(pod, containerName); exists != nil {
|
||||||
|
fmt.Fprintf(w, "Defaulting container name to container %s.\n", containerName)
|
||||||
return containerName
|
return containerName
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(w, "Default container name %q in annotation not found in a pod\n", containerName)
|
fmt.Fprintf(w, "Default container name %q in annotation not found in a pod\n", containerName)
|
||||||
|
Loading…
Reference in New Issue
Block a user