forked from btobolaski/terraform-provider-linode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
39 lines (31 loc) · 923 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
38
39
package main
import (
"fmt"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/taoh/linodego"
)
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"key": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("LINODE_API_KEY", nil),
Description: "The api key that allows you access to your linode account",
},
},
ResourcesMap: map[string]*schema.Resource{
"linode_linode": resourceLinodeLinode(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
client := linodego.NewClient(d.Get("key").(string), nil)
_, err := client.Avail.Kernels()
if err != nil {
return nil, fmt.Errorf("Failed to connect to the linode api because %s", err)
}
return client, nil
}