2014-08-25 20:48:20 +02:00
|
|
|
package google
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
2014-09-28 20:51:39 +02:00
|
|
|
"github.com/hashicorp/terraform/terraform"
|
2014-08-25 20:48:20 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Provider returns a terraform.ResourceProvider.
|
2014-09-28 20:51:39 +02:00
|
|
|
func Provider() terraform.ResourceProvider {
|
2014-08-25 20:48:20 +02:00
|
|
|
return &schema.Provider{
|
|
|
|
Schema: map[string]*schema.Schema{
|
|
|
|
"account_file": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
"client_secrets_file": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
},
|
2014-08-25 21:55:08 +02:00
|
|
|
|
|
|
|
"project": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
"region": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
},
|
2014-08-25 20:48:20 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
2014-08-25 21:55:08 +02:00
|
|
|
"google_compute_address": resourceComputeAddress(),
|
2014-08-26 01:23:28 +02:00
|
|
|
"google_compute_disk": resourceComputeDisk(),
|
2014-08-26 07:09:38 +02:00
|
|
|
"google_compute_firewall": resourceComputeFirewall(),
|
2014-08-25 20:48:20 +02:00
|
|
|
"google_compute_instance": resourceComputeInstance(),
|
2014-08-26 06:41:15 +02:00
|
|
|
"google_compute_network": resourceComputeNetwork(),
|
2014-08-26 07:39:29 +02:00
|
|
|
"google_compute_route": resourceComputeRoute(),
|
2014-08-25 20:48:20 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
ConfigureFunc: providerConfigure,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
|
|
config := Config{
|
|
|
|
AccountFile: d.Get("account_file").(string),
|
|
|
|
ClientSecretsFile: d.Get("client_secrets_file").(string),
|
2014-08-25 21:55:08 +02:00
|
|
|
Project: d.Get("project").(string),
|
|
|
|
Region: d.Get("region").(string),
|
2014-08-25 20:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := config.loadAndValidate(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2014-08-25 21:55:08 +02:00
|
|
|
return &config, nil
|
2014-08-25 20:48:20 +02:00
|
|
|
}
|