Skip to content

Commit

Permalink
Expose SDK settings TLD and URLTemplate: fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
amigus committed Feb 8, 2020
1 parent 516771c commit f68e2aa
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions provider.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
package main

import (
"log"

"github.com/hashicorp/terraform/helper/schema"
"github.com/thycotic/dsv-sdk-go/vault"
)

func providerConfig(d *schema.ResourceData) (interface{}, error) {
return vault.Configuration{
c := vault.Configuration{
Tenant: d.Get("tenant").(string),
Credentials: vault.ClientCredential{
ClientID: d.Get("client_id").(string),
ClientSecret: d.Get("client_secret").(string),
},
}, nil
}

log.Printf("[DEBUG] tenant is set to %s", c.Tenant)

if tld, ok := d.GetOk("tld"); ok {
c.TLD = tld.(string)
log.Printf("[DEBUG] tld is set to %s", c.TLD)
}

if ut, ok := d.GetOk("url_template"); ok {
c.URLTemplate = ut.(string)
log.Printf("[DEBUG] url_template is set to %s", c.URLTemplate)
}
return c, nil
}

// Provider is a Terraform DataSource
Expand All @@ -39,9 +54,20 @@ func Provider() *schema.Provider {
},
"client_secret": {
Type: schema.TypeString,
Sensitive: true,
Required: true,
Description: "The DevOps Secrets Vault client_secret",
},
"tld": {
Type: schema.TypeString,
Optional: true,
Description: "The DSV tenant top-level domain",
},
"url_template": {
Type: schema.TypeString,
Optional: true,
Description: "The DSV SDK API URL template",
},
},
ConfigureFunc: providerConfig,
}
Expand Down

0 comments on commit f68e2aa

Please sign in to comment.