Skip to content

Commit

Permalink
config: compatibility with new version client
Browse files Browse the repository at this point in the history
  • Loading branch information
pearkes committed Jun 21, 2018
1 parent b64d00e commit 5e12c34
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions consul/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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 != "" {
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5e12c34

Please sign in to comment.