-
Notifications
You must be signed in to change notification settings - Fork 1
/
provider.go
38 lines (34 loc) · 959 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
34
35
36
37
38
package main
import (
"github.com/algolia/algoliasearch-client-go/algolia/search"
"github.com/hashicorp/terraform/helper/schema"
)
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"application_id": {
Type: schema.TypeString,
Required: true,
Description: "Algolia Application ID",
},
"api_key": {
Type: schema.TypeString,
Required: true,
Description: "Algolia Admin API Key",
},
},
ResourcesMap: map[string]*schema.Resource{
"algolia_api_key": resourceAPIKey(),
},
DataSourcesMap: map[string]*schema.Resource{
"algolia_api_key": dataSourceAPIKey(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(data *schema.ResourceData) (interface{}, error) {
applicationID := data.Get("application_id").(string)
apiKey := data.Get("api_key").(string)
client := search.NewClient(applicationID, apiKey)
return client, nil
}