Skip to content

Commit

Permalink
ignore tls error
Browse files Browse the repository at this point in the history
  • Loading branch information
saamalik committed Jan 28, 2021
1 parent 9be25b1 commit 6a086c1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion spectrocloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package spectrocloud

import (
"context"
"crypto/tls"
"github.com/spectrocloud/terraform-provider-spectrocloud/pkg/client"
"net/http"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -32,6 +34,10 @@ func New(_ string) func() *schema.Provider {
Type: schema.TypeString,
Optional: true,
},
"ignore_insecure_tls_error": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
},
},
ResourcesMap: map[string]*schema.Resource{
"spectrocloud_cluster_profile": resourceClusterProfile(),
Expand Down Expand Up @@ -68,8 +74,8 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
host := d.Get("host").(string)
username := d.Get("username").(string)
password := d.Get("password").(string)

projectName := d.Get("project_name").(string)
ignoreTlsError := d.Get("ignore_insecure_tls_error").(bool)

// Warning or errors can be collected in a slice type
var diags diag.Diagnostics
Expand All @@ -84,6 +90,10 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
return nil, diags
}

if ignoreTlsError {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}

c := client.New(host, username, password, "")

if projectName != "" {
Expand Down

0 comments on commit 6a086c1

Please sign in to comment.