-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprovider.go
41 lines (34 loc) · 1.11 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
package main
import (
"log"
"github.com/hashicorp/terraform/helper/schema"
)
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"domain": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("MANAGEMENT_API_DOMAIN", nil),
},
"access_token": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("MANAGEMENT_API_ACCESS_TOKEN", nil),
},
},
ResourcesMap: map[string]*schema.Resource{
"auth0_client": resourceClient(),
"auth0_grant": resourceGrant(),
},
ConfigureFunc: providerConfigure,
}
}
type Config struct {
domain string
accessToken string
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
log.Println("[INFO] Initializing Auth0 client")
return Config{domain: d.Get("domain").(string), accessToken: d.Get("access_token").(string)}, nil
}