-
Notifications
You must be signed in to change notification settings - Fork 38
/
provider.go
33 lines (29 loc) · 871 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
package main
import (
"github.com/hashicorp/terraform/helper/schema"
vscale "github.com/vscale/go-vscale"
)
// Provider returns a schema.Provider for VScale.
func Provider() *schema.Provider {
return &schema.Provider{
ResourcesMap: map[string]*schema.Resource{
"vscale_scalet": resourceScalet(),
"vscale_ssh_key": resourceSSHKey(),
"vscale_domain": resourceDomain(),
"vscale_record": resourceRecord(),
},
Schema: map[string]*schema.Schema{
"token": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("VSCALE_API_TOKEN", nil),
Description: "The token key for API operations.",
},
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
client := vscale.NewClient(d.Get("token").(string))
return client, nil
}