From bab556f7a6f6a9984bb223a20d4e7039d659a0b3 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Tue, 20 Nov 2018 13:10:59 +0200 Subject: [PATCH] kubeadm: improve hostport parsing error messages Added hostport and host/port parts to the error messages produced by ParseHostPort API. This should help users to better identify parsing issues. Fixes: kubernetes/kubeadm#1159 --- cmd/kubeadm/app/util/endpoint.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/kubeadm/app/util/endpoint.go b/cmd/kubeadm/app/util/endpoint.go index 8760aec6b0..62746bf17d 100644 --- a/cmd/kubeadm/app/util/endpoint.go +++ b/cmd/kubeadm/app/util/endpoint.go @@ -95,7 +95,7 @@ func ParseHostPort(hostport string) (string, string, error) { // if port is defined, parse and validate it if port != "" { if _, err := ParsePort(port); err != nil { - return "", "", errors.New("port must be a valid number between 1 and 65535, inclusive") + return "", "", errors.Errorf("hostport %s: port %s must be a valid number between 1 and 65535, inclusive", hostport, port) } } @@ -109,7 +109,7 @@ func ParseHostPort(hostport string) (string, string, error) { return host, port, nil } - return "", "", errors.New("host must be a valid IP address or a valid RFC-1123 DNS subdomain") + return "", "", errors.Errorf("hostport %s: host '%s' must be a valid IP address or a valid RFC-1123 DNS subdomain", hostport, host) } // ParsePort parses a string representing a TCP port.