-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprovider.go
38 lines (35 loc) · 1.18 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
package main
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/scalechamp/goss"
)
func ProviderFunc() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"token": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("SCALECHAMP_TOKEN", nil),
Description: "Key used to authentication to the ScaleChamp API, retrived from project API settings",
},
"base_url": {
Type: schema.TypeString,
Default: "https://api.scalechamp.com",
Optional: true,
Description: "Base URL to ScaleChamp API",
},
},
ResourcesMap: map[string]*schema.Resource{
"scalechamp_redis": resourceInstance("redis"),
"scalechamp_postgresql": resourceInstance("pg"),
"scalechamp_mysql": resourceInstance("mysql"),
"scalechamp_keydb_pro": resourceInstance("keydb-pro"),
"scalechamp_keydb": resourceInstance("keydb"),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
return goss.NewClient(d.Get("base_url").(string), d.Get("token").(string)), nil
}