github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/ultradns/provider.go (about) 1 package ultradns 2 3 import ( 4 "github.com/Ensighten/udnssdk" 5 "github.com/hashicorp/terraform/helper/schema" 6 "github.com/hashicorp/terraform/terraform" 7 ) 8 9 // Provider returns a terraform.ResourceProvider. 10 func Provider() terraform.ResourceProvider { 11 return &schema.Provider{ 12 Schema: map[string]*schema.Schema{ 13 "username": &schema.Schema{ 14 Type: schema.TypeString, 15 Required: true, 16 DefaultFunc: schema.EnvDefaultFunc("ULTRADNS_USERNAME", nil), 17 Description: "UltraDNS Username.", 18 }, 19 20 "password": &schema.Schema{ 21 Type: schema.TypeString, 22 Required: true, 23 DefaultFunc: schema.EnvDefaultFunc("ULTRADNS_PASSWORD", nil), 24 Description: "UltraDNS User Password", 25 }, 26 "baseurl": &schema.Schema{ 27 Type: schema.TypeString, 28 Optional: true, 29 DefaultFunc: schema.EnvDefaultFunc("ULTRADNS_BASEURL", nil), 30 Default: udnssdk.DefaultLiveBaseURL, 31 Description: "UltraDNS Base URL", 32 }, 33 }, 34 35 ResourcesMap: map[string]*schema.Resource{ 36 "ultradns_dirpool": resourceUltradnsDirpool(), 37 "ultradns_probe_http": resourceUltradnsProbeHTTP(), 38 "ultradns_probe_ping": resourceUltradnsProbePing(), 39 "ultradns_record": resourceUltradnsRecord(), 40 "ultradns_tcpool": resourceUltradnsTcpool(), 41 "ultradns_rdpool": resourceUltradnsRdpool(), 42 }, 43 44 ConfigureFunc: providerConfigure, 45 } 46 } 47 48 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 49 config := Config{ 50 Username: d.Get("username").(string), 51 Password: d.Get("password").(string), 52 BaseURL: d.Get("baseurl").(string), 53 } 54 55 return config.Client() 56 }