Merge pull request #1537 from ggiamarchi/openstack/insecure_https

OpenStack - Allow to disable HTTPS certificate check
This commit is contained in:
Paul Hinze 2015-04-15 15:03:26 -05:00
commit 9053cc3d18
3 changed files with 26 additions and 1 deletions

View File

@ -1,6 +1,9 @@
package openstack
import (
"crypto/tls"
"net/http"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack"
)
@ -15,6 +18,7 @@ type Config struct {
TenantName string
DomainID string
DomainName string
Insecure bool
osClient *gophercloud.ProviderClient
}
@ -32,7 +36,19 @@ func (c *Config) loadAndValidate() error {
DomainName: c.DomainName,
}
client, err := openstack.AuthenticatedClient(ao)
client, err := openstack.NewClient(ao.IdentityEndpoint)
if err != nil {
return err
}
if c.Insecure {
// Configure custom TLS settings.
config := &tls.Config{InsecureSkipVerify: true}
transport := &http.Transport{TLSClientConfig: config}
client.HTTPClient.Transport = transport
}
err = openstack.Authenticate(client, ao)
if err != nil {
return err
}

View File

@ -56,6 +56,11 @@ func Provider() terraform.ResourceProvider {
Optional: true,
Default: "",
},
"insecure": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
ResourcesMap: map[string]*schema.Resource{
@ -93,6 +98,7 @@ func configureProvider(d *schema.ResourceData) (interface{}, error) {
TenantName: d.Get("tenant_name").(string),
DomainID: d.Get("domain_id").(string),
DomainName: d.Get("domain_name").(string),
Insecure: d.Get("insecure").(bool),
}
if err := config.loadAndValidate(); err != nil {

View File

@ -57,6 +57,9 @@ The following arguments are supported:
* `tenant_name` - (Optional) If omitted, the `OS_TENANT_NAME` environment
variable is used.
* `insecure` - (Optional) Explicitly allow the provider to perform
"insecure" SSL requests. If omitted, default value is `false`
## Testing
In order to run the Acceptance Tests for development, the following environment