Fix problem specifying fqdn:port in command line

When specifying --server in kubectl for example, we end up
with failure if you use "localhost:8080" instead of
"127.0.0.1:8080". This is because of the way url.Parse
works as shown in snippet:
https://play.golang.org/p/luD57S6sEz

Essentially localhost ends up as the Scheme and NOT as the Host.
So we add another check to make sure we prepend the scheme
when Host ends up being empty as well. Tested with
"kubectl --server localhost:8080 get po"

Fixes #2967
pull/6/head
Davanum Srinivas 2016-06-14 09:00:42 -07:00
parent 4ee877c226
commit 0d86251f5f
No known key found for this signature in database
GPG Key ID: 80D83A796103BF59
1 changed files with 1 additions and 1 deletions

View File

@ -36,7 +36,7 @@ func DefaultServerURL(host, apiPath string, groupVersion unversioned.GroupVersio
if err != nil { if err != nil {
return nil, "", err return nil, "", err
} }
if hostURL.Scheme == "" { if hostURL.Scheme == "" || hostURL.Host == "" {
scheme := "http://" scheme := "http://"
if defaultTLS { if defaultTLS {
scheme = "https://" scheme = "https://"