-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
provider.go
49 lines (41 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
46
47
48
49
package improvmx
import (
"sync"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
improvmxApi "github.com/issyl0/go-improvmx"
)
type Meta struct {
Resource *schema.ResourceData
Client *improvmxApi.Client
Mutex sync.Mutex
}
func Provider() *schema.Provider {
p := &schema.Provider{
Schema: map[string]*schema.Schema{
"token": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("IMPROVMX_API_TOKEN", nil),
Description: "The API token for API operations."},
},
ResourcesMap: map[string]*schema.Resource{
"improvmx_domain": resourceDomain(),
"improvmx_email_forward": resourceEmailForward(),
"improvmx_smtp_credential": resourceSMTPCredential(),
},
DataSourcesMap: map[string]*schema.Resource{
"improvmx_domain_check": DataSourceDomainCheck(),
},
ProviderMetaSchema: map[string]*schema.Schema{},
}
p.ConfigureFunc = providerConfigure
return p
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
m := &Meta{
Resource: d,
Client: improvmxApi.NewClient(d.Get("token").(string)),
Mutex: sync.Mutex{},
}
return m, nil
}