From cecc03ca8fd13795b2cabbdcf6756a4f4936782a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Martins?= Date: Tue, 21 Feb 2017 14:21:00 +0000 Subject: [PATCH] kubectl: Adding IPv6 brackets for IPv6 endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the lack of IPv6 when printing the IP:Port tuple with kubectl describe command. Signed-off-by: André Martins --- pkg/printers/internalversion/printers.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/printers/internalversion/printers.go b/pkg/printers/internalversion/printers.go index ea468d66651..57c6e779c39 100644 --- a/pkg/printers/internalversion/printers.go +++ b/pkg/printers/internalversion/printers.go @@ -20,7 +20,9 @@ import ( "bytes" "fmt" "io" + "net" "sort" + "strconv" "strings" "time" @@ -223,7 +225,8 @@ func formatEndpoints(endpoints *api.Endpoints, ports sets.String) string { } addr := &ss.Addresses[i] 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++ }