Commit 74c23bdf authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #41805 from aanm/adding-ipv6-brackets-in-kubectl-endpoint

Automatic merge from submit-queue kubectl: Adding IPv6 brackets for IPv6 endpoints This fixes the lack of IPv6 when printing the IP:Port tuple with kubectl describe command. Signed-off-by: 's avatarAndré Martins <aanm90@gmail.com> **What this PR does / why we need it**: This adds IPv6 brackets on IPv6 endpoints when using `kubectl describe service` **Special notes for your reviewer**: Since the IP is a string I think the fastest way to detect if it's an IPv6 was to check for the presence of : in it. Let me know what you think.
parents 4fa902a9 cecc03ca
...@@ -20,7 +20,9 @@ import ( ...@@ -20,7 +20,9 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io" "io"
"net"
"sort" "sort"
"strconv"
"strings" "strings"
"time" "time"
...@@ -223,7 +225,8 @@ func formatEndpoints(endpoints *api.Endpoints, ports sets.String) string { ...@@ -223,7 +225,8 @@ func formatEndpoints(endpoints *api.Endpoints, ports sets.String) string {
} }
addr := &ss.Addresses[i] addr := &ss.Addresses[i]
if !more { if !more {
list = append(list, fmt.Sprintf("%s:%d", addr.IP, port.Port)) hostPort := net.JoinHostPort(addr.IP, strconv.Itoa(int(port.Port)))
list = append(list, hostPort)
} }
count++ count++
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment