-
Notifications
You must be signed in to change notification settings - Fork 5
/
provider.go
37 lines (33 loc) · 973 Bytes
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"github.com/hashicorp/terraform/helper/schema"
)
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"apikey": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("CLOUDAMQP_APIKEY", nil),
Description: "The API key used to connect to CloudAMQP",
},
"base_url": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("CLOUDAMQP_BASE_URL", "https://customer.cloudamqp.com/api/"),
Description: "The CloudAMQP Base API URL",
},
},
ResourcesMap: map[string]*schema.Resource{
"cloudamqp_instance": resourceInstance(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
APIKey: d.Get("apikey").(string),
BaseURL: d.Get("base_url").(string),
}
return config.Client()
}