Ignores SSL verification when on premise vagrant cloud
This commit is contained in:
parent
3dc1dafe58
commit
a2fd287e56
|
@ -2,6 +2,7 @@ package vagrantcloud
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -37,13 +38,20 @@ func (v VagrantCloudErrors) FormatErrors() string {
|
|||
return strings.Join(errs, ". ")
|
||||
}
|
||||
|
||||
func (v VagrantCloudClient) New(baseUrl string, token string) (*VagrantCloudClient, error) {
|
||||
func (v VagrantCloudClient) New(baseUrl string, token string, InsecureSkipTLSVerify bool) (*VagrantCloudClient, error) {
|
||||
c := &VagrantCloudClient{
|
||||
client: commonhelper.HttpClientWithEnvironmentProxy(),
|
||||
BaseURL: baseUrl,
|
||||
AccessToken: token,
|
||||
}
|
||||
|
||||
if InsecureSkipTLSVerify {
|
||||
transport := c.client.Transport.(*http.Transport)
|
||||
transport.TLSClientConfig = &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
}
|
||||
|
||||
return c, c.ValidateAuthentication()
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,9 @@ type Config struct {
|
|||
VersionDescription string `mapstructure:"version_description"`
|
||||
NoRelease bool `mapstructure:"no_release"`
|
||||
|
||||
AccessToken string `mapstructure:"access_token"`
|
||||
VagrantCloudUrl string `mapstructure:"vagrant_cloud_url"`
|
||||
AccessToken string `mapstructure:"access_token"`
|
||||
VagrantCloudUrl string `mapstructure:"vagrant_cloud_url"`
|
||||
InsecureSkipTLSVerify bool `mapstructure:"insecure_skip_tls_verify"`
|
||||
|
||||
BoxDownloadUrl string `mapstructure:"box_download_url"`
|
||||
|
||||
|
@ -41,10 +42,11 @@ type boxDownloadUrlTemplate struct {
|
|||
}
|
||||
|
||||
type PostProcessor struct {
|
||||
config Config
|
||||
client *VagrantCloudClient
|
||||
runner multistep.Runner
|
||||
warnAtlasToken bool
|
||||
config Config
|
||||
client *VagrantCloudClient
|
||||
runner multistep.Runner
|
||||
warnAtlasToken bool
|
||||
insecureSkipTLSVerify bool
|
||||
}
|
||||
|
||||
func (p *PostProcessor) Configure(raws ...interface{}) error {
|
||||
|
@ -66,6 +68,8 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
|
|||
p.config.VagrantCloudUrl = VAGRANT_CLOUD_URL
|
||||
}
|
||||
|
||||
p.insecureSkipTLSVerify = p.config.InsecureSkipTLSVerify == true && p.config.VagrantCloudUrl != VAGRANT_CLOUD_URL
|
||||
|
||||
if p.config.AccessToken == "" {
|
||||
envToken := os.Getenv("VAGRANT_CLOUD_TOKEN")
|
||||
if envToken == "" {
|
||||
|
@ -95,7 +99,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
|
|||
}
|
||||
|
||||
// create the HTTP client
|
||||
p.client, err = VagrantCloudClient{}.New(p.config.VagrantCloudUrl, p.config.AccessToken)
|
||||
p.client, err = VagrantCloudClient{}.New(p.config.VagrantCloudUrl, p.config.AccessToken, p.insecureSkipTLSVerify)
|
||||
if err != nil {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, fmt.Errorf("Failed to verify authentication token: %v", err))
|
||||
|
|
Loading…
Reference in New Issue