github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/vcd/provider.go (about) 1 package vcd 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 "user": &schema.Schema{ 13 Type: schema.TypeString, 14 Required: true, 15 DefaultFunc: schema.EnvDefaultFunc("VCD_USER", nil), 16 Description: "The user name for vcd API operations.", 17 }, 18 19 "password": &schema.Schema{ 20 Type: schema.TypeString, 21 Required: true, 22 DefaultFunc: schema.EnvDefaultFunc("VCD_PASSWORD", nil), 23 Description: "The user password for vcd API operations.", 24 }, 25 26 "org": &schema.Schema{ 27 Type: schema.TypeString, 28 Required: true, 29 DefaultFunc: schema.EnvDefaultFunc("VCD_ORG", nil), 30 Description: "The vcd org for API operations", 31 }, 32 33 "url": &schema.Schema{ 34 Type: schema.TypeString, 35 Required: true, 36 DefaultFunc: schema.EnvDefaultFunc("VCD_URL", nil), 37 Description: "The vcd url for vcd API operations.", 38 }, 39 40 "vdc": &schema.Schema{ 41 Type: schema.TypeString, 42 Optional: true, 43 DefaultFunc: schema.EnvDefaultFunc("VCD_VDC", ""), 44 Description: "The name of the VDC to run operations on", 45 }, 46 47 "maxRetryTimeout": &schema.Schema{ 48 Type: schema.TypeInt, 49 Optional: true, 50 DefaultFunc: schema.EnvDefaultFunc("VCD_MAX_RETRY_TIMEOUT", 60), 51 Description: "Max num seconds to wait for successful response when operating on resources within vCloud (defaults to 60)", 52 }, 53 54 "allow_unverified_ssl": &schema.Schema{ 55 Type: schema.TypeBool, 56 Optional: true, 57 DefaultFunc: schema.EnvDefaultFunc("VCD_ALLOW_UNVERIFIED_SSL", false), 58 Description: "If set, VCDClient will permit unverifiable SSL certificates.", 59 }, 60 }, 61 62 ResourcesMap: map[string]*schema.Resource{ 63 "vcd_network": resourceVcdNetwork(), 64 "vcd_vapp": resourceVcdVApp(), 65 "vcd_firewall_rules": resourceVcdFirewallRules(), 66 "vcd_dnat": resourceVcdDNAT(), 67 "vcd_snat": resourceVcdSNAT(), 68 }, 69 70 ConfigureFunc: providerConfigure, 71 } 72 } 73 74 func providerConfigure(d *schema.ResourceData) (interface{}, error) { 75 config := Config{ 76 User: d.Get("user").(string), 77 Password: d.Get("password").(string), 78 Org: d.Get("org").(string), 79 Href: d.Get("url").(string), 80 VDC: d.Get("vdc").(string), 81 MaxRetryTimeout: d.Get("maxRetryTimeout").(int), 82 InsecureFlag: d.Get("allow_unverified_ssl").(bool), 83 } 84 85 return config.Client() 86 }