-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovider.go
45 lines (40 loc) · 1.15 KB
/
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
38
39
40
41
42
43
44
45
package main
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"api_dev_key": {
Type: schema.TypeString,
Required: true,
Description: "The api_dev_key for API operations.",
},
"api_user_name": {
Type: schema.TypeString,
Required: true,
Description: "The api_user_name for API operations.",
},
"api_user_password": {
Type: schema.TypeString,
Required: true,
Description: "The api_user_password for API operations.",
},
},
ResourcesMap: map[string]*schema.Resource{
"pastebin_api_user_key": resourceAPIUserKey(),
"pastebin_create_paste": resourceCreatePaste(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
ApiUserName: d.Get("api_user_name").(string),
ApiUserPassword: d.Get("api_user_password").(string),
ApiDevKey: d.Get("api_dev_key").(string),
BaseUrl: "https://pastebin.com/",
}
return &config, nil
}