Browse Source

Update docs and give better error for unknown client scheme

pull/2730/head
Kyle Havlovitz 8 years ago
parent
commit
c9abafab92
No known key found for this signature in database
GPG Key ID: 8A5E6B173056AD6C
  1. 8
      api/api.go
  2. 5
      command/agent/command.go
  3. 6
      website/source/docs/commands/_http_api_options_client.html.markdown

8
api/api.go

@ -348,9 +348,11 @@ func NewClient(config *Config) (*Client, error) {
parts := strings.SplitN(config.Address, "://", 2)
if len(parts) == 2 {
if parts[0] == "https" {
switch parts[0] {
case "http":
case "https":
config.Scheme = "https"
} else if parts[0] == "unix" {
case "unix":
trans := cleanhttp.DefaultTransport()
trans.Dial = func(_, _ string) (net.Conn, error) {
return net.Dial("unix", parts[1])
@ -358,6 +360,8 @@ func NewClient(config *Config) (*Client, error) {
config.HttpClient = &http.Client{
Transport: trans,
}
default:
return nil, fmt.Errorf("Unknown protocol scheme: %s", parts[0])
}
config.Address = parts[1]
}

5
command/agent/command.go

@ -1086,8 +1086,11 @@ func (c *Command) Run(args []string) int {
var err error
if config.Ports.HTTP != -1 {
httpAddr, err = config.ClientListener(config.Addresses.HTTP, config.Ports.HTTP)
} else {
} else if config.Ports.HTTPS != -1 {
httpAddr, err = config.ClientListener(config.Addresses.HTTPS, config.Ports.HTTPS)
} else if len(config.WatchPlans) > 0 {
c.Ui.Error("Error: cannot use watches if both HTTP and HTTPS are disabled")
return 1
}
if err != nil {
c.Ui.Error(fmt.Sprintf("Failed to determine HTTP address: %v", err))

6
website/source/docs/commands/_http_api_options_client.html.markdown

@ -1,7 +1,9 @@
* `-http-addr=<addr>` - Address of the Consul agent with the port. This can be
an IP address or DNS address, but it must include the port. This can also be
specified via the `CONSUL_HTTP_ADDR` environment variable. The default value is
127.0.0.1:8500.
specified via the `CONSUL_HTTP_ADDR` environment variable. In Consul 0.8 and
later, the default value is http://127.0.0.1:8500, and https can optionally
be used instead. The scheme can also be set to HTTPS by setting the
environment variable `CONSUL_HTTP_SSL=true`.
* `-token=<value>` - ACL token to use in the request. This can also be specified
via the `CONSUL_HTTP_TOKEN` environment variable. If unspecified, the query

Loading…
Cancel
Save