mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Merge pull request #45474 from xiangpengzhao/fix-port-none
Automatic merge from submit-queue (batch tested with PRs 41903, 45311, 45474, 45472, 45501) Display <none> when port is empty. **What this PR does / why we need it**: If container ports are not specified, `kubectl describe` displays `<none>` instead of empty. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
commit
d092fc546b
@ -1072,9 +1072,13 @@ func describeContainerBasicInfo(container api.Container, status api.ContainerSta
|
|||||||
portString := describeContainerPorts(container.Ports)
|
portString := describeContainerPorts(container.Ports)
|
||||||
if strings.Contains(portString, ",") {
|
if strings.Contains(portString, ",") {
|
||||||
w.Write(LEVEL_2, "Ports:\t%s\n", portString)
|
w.Write(LEVEL_2, "Ports:\t%s\n", portString)
|
||||||
|
} else {
|
||||||
|
if len(portString) == 0 {
|
||||||
|
w.Write(LEVEL_2, "Port:\t<none>\n")
|
||||||
} else {
|
} else {
|
||||||
w.Write(LEVEL_2, "Port:\t%s\n", portString)
|
w.Write(LEVEL_2, "Port:\t%s\n", portString)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func describeContainerPorts(cPorts []api.ContainerPort) string {
|
func describeContainerPorts(cPorts []api.ContainerPort) string {
|
||||||
|
Loading…
Reference in New Issue
Block a user