mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Change to include UID by default in formatting
This commit is contained in:
parent
33eda2ffb5
commit
fda73c04ec
@ -25,26 +25,18 @@ import (
|
|||||||
|
|
||||||
type podHandler func(*api.Pod) string
|
type podHandler func(*api.Pod) string
|
||||||
|
|
||||||
// Pod returns a string representating a pod in a human readable
|
// Pod returns a string reprenetating a pod in a human readable format,
|
||||||
// format. This function currently is the same as GetPodFullName in
|
// with pod UID as part of the string.
|
||||||
// kubelet/containers, but may differ in the future. As opposed to
|
|
||||||
// GetPodFullName, this function is mainly used for logging.
|
|
||||||
func Pod(pod *api.Pod) string {
|
func Pod(pod *api.Pod) string {
|
||||||
// Use underscore as the delimiter because it is not allowed in pod name
|
// Use underscore as the delimiter because it is not allowed in pod name
|
||||||
// (DNS subdomain format), while allowed in the container name format.
|
// (DNS subdomain format), while allowed in the container name format.
|
||||||
return fmt.Sprintf("%s_%s", pod.Name, pod.Namespace)
|
return fmt.Sprintf("%s_%s(%s)", pod.Name, pod.Namespace, pod.UID)
|
||||||
}
|
|
||||||
|
|
||||||
// PodWithUID returns a string reprenetating a pod in a human readable format,
|
|
||||||
// with pod UID as part of the string.
|
|
||||||
func PodWithUID(pod *api.Pod) string {
|
|
||||||
return fmt.Sprintf("%s(%s)", Pod(pod), pod.UID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pods returns a string representating a list of pods in a human
|
// Pods returns a string representating a list of pods in a human
|
||||||
// readable format.
|
// readable format.
|
||||||
func Pods(pods []*api.Pod) string {
|
func Pods(pods []*api.Pod) string {
|
||||||
return aggregatePods(pods, PodWithUID)
|
return aggregatePods(pods, Pod)
|
||||||
}
|
}
|
||||||
|
|
||||||
func aggregatePods(pods []*api.Pod, handler podHandler) string {
|
func aggregatePods(pods []*api.Pod, handler podHandler) string {
|
||||||
|
Loading…
Reference in New Issue
Block a user