From 5e12c34ed2f7de9f58aea90070f97357cc99f6f2 Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Wed, 23 May 2018 17:14:48 -0700 Subject: [PATCH] config: compatibility with new version client ref: https://github.com/hashicorp/consul/issues/2922 --- consul/config.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/consul/config.go b/consul/config.go index 4eeb7760..f81c5bc6 100644 --- a/consul/config.go +++ b/consul/config.go @@ -3,12 +3,12 @@ package consul import ( "fmt" "log" - "net/http" "strings" consulapi "github.com/hashicorp/consul/api" ) +// Config is configuration defined in the provider block type Config struct { Datacenter string `mapstructure:"datacenter"` Address string `mapstructure:"address"` @@ -21,8 +21,7 @@ type Config struct { InsecureHttps bool `mapstructure:"insecure_https"` } -// Client() returns a new client for accessing consul. -// +// Client returns a new client for accessing consul. func (c *Config) Client() (*consulapi.Client, error) { config := consulapi.DefaultConfig() if c.Datacenter != "" { @@ -35,7 +34,7 @@ func (c *Config) Client() (*consulapi.Client, error) { config.Scheme = c.Scheme } - tlsConfig := &consulapi.TLSConfig{} + tlsConfig := consulapi.TLSConfig{} tlsConfig.CAFile = c.CAFile tlsConfig.CertFile = c.CertFile tlsConfig.KeyFile = c.KeyFile @@ -45,11 +44,12 @@ func (c *Config) Client() (*consulapi.Client, error) { } tlsConfig.InsecureSkipVerify = c.InsecureHttps } - cc, err := consulapi.SetupTLSConfig(tlsConfig) + + var err error + config.HttpClient, err = consulapi.NewHttpClient(config.Transport, tlsConfig) if err != nil { - return nil, err + return nil, fmt.Errorf("Failed to create http client: %s", err) } - config.HttpClient.Transport.(*http.Transport).TLSClientConfig = cc if c.HttpAuth != "" { var username, password string