From a7a6ee9f4cc86afcd6406299a0906c93f136e04e Mon Sep 17 00:00:00 2001 From: Kyle Havlovitz Date: Fri, 10 Feb 2017 18:08:39 -0500 Subject: [PATCH] Allow prefixing -http-addr with http/https schemes --- api/api.go | 19 ++++++++++++------- command/base/command.go | 3 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/api/api.go b/api/api.go index ee7cecfeba..f291ad78e7 100644 --- a/api/api.go +++ b/api/api.go @@ -346,13 +346,18 @@ func NewClient(config *Config) (*Client, error) { config.HttpClient = defConfig.HttpClient } - if parts := strings.SplitN(config.Address, "unix://", 2); len(parts) == 2 { - trans := cleanhttp.DefaultTransport() - trans.Dial = func(_, _ string) (net.Conn, error) { - return net.Dial("unix", parts[1]) - } - config.HttpClient = &http.Client{ - Transport: trans, + parts := strings.SplitN(config.Address, "://", 2) + if len(parts) == 2 { + if parts[0] == "https" { + config.Scheme = "https" + } else if parts[0] == "unix" { + trans := cleanhttp.DefaultTransport() + trans.Dial = func(_, _ string) (net.Conn, error) { + return net.Dial("unix", parts[1]) + } + config.HttpClient = &http.Client{ + Transport: trans, + } } config.Address = parts[1] } diff --git a/command/base/command.go b/command/base/command.go index a9fd6db661..744fa066b2 100644 --- a/command/base/command.go +++ b/command/base/command.go @@ -86,7 +86,8 @@ func (c *Command) httpFlagsClient(f *flag.FlagSet) *flag.FlagSet { "The `address` and port of the Consul HTTP agent. The value can be an IP "+ "address or DNS address, but it must also include the port. This can "+ "also be specified via the CONSUL_HTTP_ADDR environment variable. The "+ - "default value is 127.0.0.1:8500.") + "default value is http://127.0.0.1:8500. The scheme can also be set to "+ + "HTTPS by setting the environment variable CONSUL_HTTP_SSL=true.") f.Var(&c.token, "token", "ACL token to use in the request. This can also be specified via the "+ "CONSUL_HTTP_TOKEN environment variable. If unspecified, the query will "+