70 lines
1.9 KiB
Go
70 lines
1.9 KiB
Go
|
package vcd
|
||
|
|
||
|
import (
|
||
|
"github.com/hashicorp/terraform/helper/schema"
|
||
|
"github.com/hashicorp/terraform/terraform"
|
||
|
)
|
||
|
|
||
|
// Provider returns a terraform.ResourceProvider.
|
||
|
func Provider() terraform.ResourceProvider {
|
||
|
return &schema.Provider{
|
||
|
Schema: map[string]*schema.Schema{
|
||
|
"user": &schema.Schema{
|
||
|
Type: schema.TypeString,
|
||
|
Required: true,
|
||
|
DefaultFunc: schema.EnvDefaultFunc("VCD_USER", nil),
|
||
|
Description: "The user name for vcd API operations.",
|
||
|
},
|
||
|
|
||
|
"password": &schema.Schema{
|
||
|
Type: schema.TypeString,
|
||
|
Required: true,
|
||
|
DefaultFunc: schema.EnvDefaultFunc("VCD_PASSWORD", nil),
|
||
|
Description: "The user password for vcd API operations.",
|
||
|
},
|
||
|
|
||
|
"org": &schema.Schema{
|
||
|
Type: schema.TypeString,
|
||
|
Required: true,
|
||
|
DefaultFunc: schema.EnvDefaultFunc("VCD_ORG", nil),
|
||
|
Description: "The vcd org for API operations",
|
||
|
},
|
||
|
|
||
|
"url": &schema.Schema{
|
||
|
Type: schema.TypeString,
|
||
|
Required: true,
|
||
|
DefaultFunc: schema.EnvDefaultFunc("VCD_URL", nil),
|
||
|
Description: "The vcd url for vcd API operations.",
|
||
|
},
|
||
|
"vdc": &schema.Schema{
|
||
|
Type: schema.TypeString,
|
||
|
Optional: true,
|
||
|
DefaultFunc: schema.EnvDefaultFunc("VCD_VDC", ""),
|
||
|
Description: "The name of the VDC to run operations on",
|
||
|
},
|
||
|
},
|
||
|
|
||
|
ResourcesMap: map[string]*schema.Resource{
|
||
|
"vcd_network": resourceVcdNetwork(),
|
||
|
"vcd_vapp": resourceVcdVApp(),
|
||
|
"vcd_firewall_rules": resourceVcdFirewallRules(),
|
||
|
"vcd_dnat": resourceVcdDNAT(),
|
||
|
"vcd_snat": resourceVcdSNAT(),
|
||
|
},
|
||
|
|
||
|
ConfigureFunc: providerConfigure,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
||
|
config := Config{
|
||
|
User: d.Get("user").(string),
|
||
|
Password: d.Get("password").(string),
|
||
|
Org: d.Get("org").(string),
|
||
|
Href: d.Get("url").(string),
|
||
|
VDC: d.Get("vdc").(string),
|
||
|
}
|
||
|
|
||
|
return config.Client()
|
||
|
}
|