mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #1537 from ggiamarchi/openstack/insecure_https
OpenStack - Allow to disable HTTPS certificate check
This commit is contained in:
commit
9053cc3d18
@ -1,6 +1,9 @@
|
|||||||
package openstack
|
package openstack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/rackspace/gophercloud"
|
"github.com/rackspace/gophercloud"
|
||||||
"github.com/rackspace/gophercloud/openstack"
|
"github.com/rackspace/gophercloud/openstack"
|
||||||
)
|
)
|
||||||
@ -15,6 +18,7 @@ type Config struct {
|
|||||||
TenantName string
|
TenantName string
|
||||||
DomainID string
|
DomainID string
|
||||||
DomainName string
|
DomainName string
|
||||||
|
Insecure bool
|
||||||
|
|
||||||
osClient *gophercloud.ProviderClient
|
osClient *gophercloud.ProviderClient
|
||||||
}
|
}
|
||||||
@ -32,7 +36,19 @@ func (c *Config) loadAndValidate() error {
|
|||||||
DomainName: c.DomainName,
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,11 @@ func Provider() terraform.ResourceProvider {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "",
|
Default: "",
|
||||||
},
|
},
|
||||||
|
"insecure": &schema.Schema{
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
ResourcesMap: map[string]*schema.Resource{
|
ResourcesMap: map[string]*schema.Resource{
|
||||||
@ -93,6 +98,7 @@ func configureProvider(d *schema.ResourceData) (interface{}, error) {
|
|||||||
TenantName: d.Get("tenant_name").(string),
|
TenantName: d.Get("tenant_name").(string),
|
||||||
DomainID: d.Get("domain_id").(string),
|
DomainID: d.Get("domain_id").(string),
|
||||||
DomainName: d.Get("domain_name").(string),
|
DomainName: d.Get("domain_name").(string),
|
||||||
|
Insecure: d.Get("insecure").(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := config.loadAndValidate(); err != nil {
|
if err := config.loadAndValidate(); err != nil {
|
||||||
|
@ -57,6 +57,9 @@ The following arguments are supported:
|
|||||||
* `tenant_name` - (Optional) If omitted, the `OS_TENANT_NAME` environment
|
* `tenant_name` - (Optional) If omitted, the `OS_TENANT_NAME` environment
|
||||||
variable is used.
|
variable is used.
|
||||||
|
|
||||||
|
* `insecure` - (Optional) Explicitly allow the provider to perform
|
||||||
|
"insecure" SSL requests. If omitted, default value is `false`
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
In order to run the Acceptance Tests for development, the following environment
|
In order to run the Acceptance Tests for development, the following environment
|
||||||
|
Loading…
Reference in New Issue
Block a user