Merge pull request #3993 from mitchellh/f-atlas-tls-noverify
Update atlas-go to get ATLAS_TLS_NOVERIFY option for packer push command
This commit is contained in:
commit
6e497573e6
|
@ -50,6 +50,12 @@ func (o *ArchiveOpts) IsSet() bool {
|
||||||
return len(o.Exclude) > 0 || len(o.Include) > 0 || o.VCS
|
return len(o.Exclude) > 0 || len(o.Include) > 0 || o.VCS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constants related to setting special values for Extra in ArchiveOpts.
|
||||||
|
const (
|
||||||
|
// ExtraEntryDir just creates the Extra key as a directory entry.
|
||||||
|
ExtraEntryDir = ""
|
||||||
|
)
|
||||||
|
|
||||||
// CreateArchive takes the given path and ArchiveOpts and archives it.
|
// CreateArchive takes the given path and ArchiveOpts and archives it.
|
||||||
//
|
//
|
||||||
// The archive will be fully completed and put into a temporary file.
|
// The archive will be fully completed and put into a temporary file.
|
||||||
|
@ -419,7 +425,29 @@ func copyConcreteEntry(
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyExtras(w *tar.Writer, extra map[string]string) error {
|
func copyExtras(w *tar.Writer, extra map[string]string) error {
|
||||||
|
var tmpDir string
|
||||||
|
defer func() {
|
||||||
|
if tmpDir != "" {
|
||||||
|
os.RemoveAll(tmpDir)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
for entry, path := range extra {
|
for entry, path := range extra {
|
||||||
|
// If the path is empty, then we set it to a generic empty directory
|
||||||
|
if path == "" {
|
||||||
|
// If tmpDir is still empty, then we create an empty dir
|
||||||
|
if tmpDir == "" {
|
||||||
|
td, err := ioutil.TempDir("", "archive")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpDir = td
|
||||||
|
}
|
||||||
|
|
||||||
|
path = tmpDir
|
||||||
|
}
|
||||||
|
|
||||||
info, err := os.Stat(path)
|
info, err := os.Stat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -34,6 +34,11 @@ const (
|
||||||
// load trusted certs from a directory
|
// load trusted certs from a directory
|
||||||
atlasCAPathEnvVar = "ATLAS_CAPATH"
|
atlasCAPathEnvVar = "ATLAS_CAPATH"
|
||||||
|
|
||||||
|
// atlasTLSNoVerifyEnvVar disables TLS verification, similar to curl -k
|
||||||
|
// This defaults to false (verify) and will change to true (skip
|
||||||
|
// verification) with any non-empty value
|
||||||
|
atlasTLSNoVerifyEnvVar = "ATLAS_TLS_NOVERIFY"
|
||||||
|
|
||||||
// atlasTokenHeader is the header key used for authenticating with Atlas
|
// atlasTokenHeader is the header key used for authenticating with Atlas
|
||||||
atlasTokenHeader = "X-Atlas-Token"
|
atlasTokenHeader = "X-Atlas-Token"
|
||||||
)
|
)
|
||||||
|
@ -70,6 +75,10 @@ type Client struct {
|
||||||
|
|
||||||
// HTTPClient is the underlying http client with which to make requests.
|
// HTTPClient is the underlying http client with which to make requests.
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
|
|
||||||
|
// DefaultHeaders is a set of headers that will be added to every request.
|
||||||
|
// This minimally includes the atlas user-agent string.
|
||||||
|
DefaultHeader http.Header
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultClient returns a client that connects to the Atlas API.
|
// DefaultClient returns a client that connects to the Atlas API.
|
||||||
|
@ -108,10 +117,13 @@ func NewClient(urlString string) (*Client, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
client := &Client{
|
client := &Client{
|
||||||
URL: parsedURL,
|
URL: parsedURL,
|
||||||
Token: token,
|
Token: token,
|
||||||
|
DefaultHeader: make(http.Header),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.DefaultHeader.Set("User-Agent", userAgent)
|
||||||
|
|
||||||
if err := client.init(); err != nil {
|
if err := client.init(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -123,6 +135,9 @@ func NewClient(urlString string) (*Client, error) {
|
||||||
func (c *Client) init() error {
|
func (c *Client) init() error {
|
||||||
c.HTTPClient = cleanhttp.DefaultClient()
|
c.HTTPClient = cleanhttp.DefaultClient()
|
||||||
tlsConfig := &tls.Config{}
|
tlsConfig := &tls.Config{}
|
||||||
|
if os.Getenv(atlasTLSNoVerifyEnvVar) != "" {
|
||||||
|
tlsConfig.InsecureSkipVerify = true
|
||||||
|
}
|
||||||
err := rootcerts.ConfigureTLS(tlsConfig, &rootcerts.Config{
|
err := rootcerts.ConfigureTLS(tlsConfig, &rootcerts.Config{
|
||||||
CAFile: os.Getenv(atlasCAFileEnvVar),
|
CAFile: os.Getenv(atlasCAFileEnvVar),
|
||||||
CAPath: os.Getenv(atlasCAPathEnvVar),
|
CAPath: os.Getenv(atlasCAPathEnvVar),
|
||||||
|
@ -227,10 +242,12 @@ func (c *Client) rawRequest(verb string, u *url.URL, ro *RequestOptions) (*http.
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the User-Agent
|
// set our default headers first
|
||||||
request.Header.Set("User-Agent", userAgent)
|
for k, v := range c.DefaultHeader {
|
||||||
|
request.Header[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
// Add any headers (auth will be here if set)
|
// Add any request headers (auth will be here if set)
|
||||||
for k, v := range ro.Headers {
|
for k, v := range ro.Headers {
|
||||||
request.Header.Add(k, v)
|
request.Header.Add(k, v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,16 @@ type TerraformConfigVersion struct {
|
||||||
Version int
|
Version int
|
||||||
Remotes []string `json:"remotes"`
|
Remotes []string `json:"remotes"`
|
||||||
Metadata map[string]string `json:"metadata"`
|
Metadata map[string]string `json:"metadata"`
|
||||||
Variables map[string]string `json:"variables"`
|
Variables map[string]string `json:"variables,omitempty"`
|
||||||
|
TFVars []TFVar `json:"tf_vars"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TFVar is used to serialize a single Terraform variable sent by the
|
||||||
|
// manager as a collection of Variables in a Job payload.
|
||||||
|
type TFVar struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
IsHCL bool `json:"hcl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TerraformConfigLatest returns the latest Terraform configuration version.
|
// TerraformConfigLatest returns the latest Terraform configuration version.
|
||||||
|
|
|
@ -339,16 +339,18 @@
|
||||||
"revision": "2a60fc2ba6c19de80291203597d752e9ba58e4c0"
|
"revision": "2a60fc2ba6c19de80291203597d752e9ba58e4c0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "PugKTD0dIXDRlyjtzeimgjT7+ZM=",
|
"checksumSHA1": "FUiF2WLrih0JdHsUTMMDz3DRokw=",
|
||||||
"comment": "20141209094003-92-g95fa852",
|
"comment": "20141209094003-92-g95fa852",
|
||||||
"path": "github.com/hashicorp/atlas-go/archive",
|
"path": "github.com/hashicorp/atlas-go/archive",
|
||||||
"revision": "95fa852edca41c06c4ce526af4bb7dec4eaad434"
|
"revision": "a32da833807becb5b150e125c859e01b707e74ca",
|
||||||
|
"revisionTime": "2016-10-12T21:43:57Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "OylSuPrtMLP6yvPKTx60ptqQO6I=",
|
"checksumSHA1": "aD7uHoVmfg2T9mpnVZ5dWe6rGtY=",
|
||||||
"comment": "20141209094003-92-g95fa852",
|
"comment": "20141209094003-92-g95fa852",
|
||||||
"path": "github.com/hashicorp/atlas-go/v1",
|
"path": "github.com/hashicorp/atlas-go/v1",
|
||||||
"revision": "95fa852edca41c06c4ce526af4bb7dec4eaad434"
|
"revision": "a32da833807becb5b150e125c859e01b707e74ca",
|
||||||
|
"revisionTime": "2016-10-12T21:43:57Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "cdOCt0Yb+hdErz8NAQqayxPmRsY=",
|
"checksumSHA1": "cdOCt0Yb+hdErz8NAQqayxPmRsY=",
|
||||||
|
|
Loading…
Reference in New Issue