-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
48 lines (40 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
42
43
44
45
46
47
48
package main
import (
"github.com/ernesto-arm/go-coveo/sourceapi"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"log"
)
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"organization_id":{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("COVEO_ORG_ID", nil),
},
"api_key":{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("COVEO_API_KEY", nil),
},
},
ResourcesMap: map[string]*schema.Resource{
"coveo_source": resourceSource(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData)(interface{}, error){
log.Printf("[INFO] getting the configuration ")
pushConfig := sourceapi.Config{
OrganizationID: d.Get("organization_id").(string),
APIKey: d.Get("api_key").(string),
}
client, err := sourceapi.NewClient(pushConfig)
if err != nil {
log.Printf("[ERROR] Coveo client errord with %s", err.Error())
return nil, err
}
log.Println("[INFO] Coveo client initialised")
return client, nil
}