Update atlas-go to latest version that uses go-rootcerts

This commit is contained in:
Paul Hinze 2016-05-03 12:12:30 -05:00
parent 4ac6dda633
commit c44062814c
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 25 additions and 4 deletions

8
Godeps/Godeps.json generated
View File

@ -673,13 +673,13 @@
},
{
"ImportPath": "github.com/hashicorp/atlas-go/archive",
"Comment": "20141209094003-90-g0008886",
"Rev": "0008886ebfa3b424bed03e2a5cbe4a2568ea0ff6"
"Comment": "20141209094003-92-g95fa852",
"Rev": "95fa852edca41c06c4ce526af4bb7dec4eaad434"
},
{
"ImportPath": "github.com/hashicorp/atlas-go/v1",
"Comment": "20141209094003-90-g0008886",
"Rev": "0008886ebfa3b424bed03e2a5cbe4a2568ea0ff6"
"Comment": "20141209094003-92-g95fa852",
"Rev": "95fa852edca41c06c4ce526af4bb7dec4eaad434"
},
{
"ImportPath": "github.com/hashicorp/consul/api",

View File

@ -2,6 +2,7 @@ package atlas
import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io"
@ -14,6 +15,7 @@ import (
"strings"
"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/go-rootcerts"
)
const (
@ -24,6 +26,14 @@ const (
// default Atlas address.
atlasEndpointEnvVar = "ATLAS_ADDRESS"
// atlasCAFileEnvVar is the environment variable that causes the client to
// load trusted certs from a file
atlasCAFileEnvVar = "ATLAS_CAFILE"
// atlasCAPathEnvVar is the environment variable that causes the client to
// load trusted certs from a directory
atlasCAPathEnvVar = "ATLAS_CAPATH"
// atlasTokenHeader is the header key used for authenticating with Atlas
atlasTokenHeader = "X-Atlas-Token"
)
@ -112,6 +122,17 @@ func NewClient(urlString string) (*Client, error) {
// init() sets defaults on the client.
func (c *Client) init() error {
c.HTTPClient = cleanhttp.DefaultClient()
tlsConfig := &tls.Config{}
err := rootcerts.ConfigureTLS(tlsConfig, &rootcerts.Config{
CAFile: os.Getenv(atlasCAFileEnvVar),
CAPath: os.Getenv(atlasCAPathEnvVar),
})
if err != nil {
return err
}
t := cleanhttp.DefaultTransport()
t.TLSClientConfig = tlsConfig
c.HTTPClient.Transport = t
return nil
}