github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/ns1/provider.go (about) 1 package ns1 2 3 import ( 4 "github.com/hashicorp/terraform/helper/schema" 5 "github.com/hashicorp/terraform/terraform" 6 ) 7 8 // Provider returns a terraform.ResourceProvider. 9 func Provider() terraform.ResourceProvider { 10 return &schema.Provider{ 11 Schema: map[string]*schema.Schema{ 12 "apikey": &schema.Schema{ 13 Type: schema.TypeString, 14 Required: true, 15 DefaultFunc: schema.EnvDefaultFunc("NS1_APIKEY", nil), 16 Description: descriptions["api_key"], 17 }, 18 "endpoint": &schema.Schema{ 19 Type: schema.TypeString, 20 Optional: true, 21 DefaultFunc: schema.EnvDefaultFunc("NS1_ENDPOINT", nil), 22 Description: descriptions["endpoint"], 23 }, 24 "ignore_ssl": &schema.Schema{ 25 Type: schema.TypeBool, 26 Optional: true, 27 DefaultFunc: schema.EnvDefaultFunc("NS1_IGNORE_SSL", nil), 28 Description: descriptions["ignore_ssl"], 29 }, 30 }, 31 ResourcesMap: map[string]*schema.Resource{ 32 "ns1_zone": zoneResource(), 33 "ns1_record": recordResource(), 34 "ns1_datasource": dataSourceResource(), 35 "ns1_datafeed": dataFeedResource(), 36 "ns1_monitoringjob": monitoringJobResource(), 37 "ns1_notifylist": notifyListResource(), 38 "ns1_user": userResource(), 39 "ns1_apikey": apikeyResource(), 40 "ns1_team": teamResource(), 41 }, 42 ConfigureFunc: ns1Configure, 43 } 44 } 45 46 func ns1Configure(d *schema.ResourceData) (interface{}, error) { 47 config := Config{ 48 Key: d.Get("apikey").(string), 49 } 50 51 if v, ok := d.GetOk("endpoint"); ok { 52 config.Endpoint = v.(string) 53 } 54 if v, ok := d.GetOk("ignore_ssl"); ok { 55 config.IgnoreSSL = v.(bool) 56 } 57 58 return config.Client() 59 } 60 61 var descriptions map[string]string 62 63 func init() { 64 descriptions = map[string]string{ 65 "api_key": "The ns1 API key, this is required", 66 } 67 }