-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
58 lines (49 loc) · 1.31 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
50
51
52
53
54
55
56
57
58
package main
import (
"net/http"
"time"
okta "github.com/curtisallen/go-okta"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
// Provider entry point for okta provider
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"organization": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "The Okta orgizantion id e.g. dev-1234",
},
"token": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("OKTA_TOKEN", nil),
Description: "Okta API token",
},
"preview": &schema.Schema{
Type: schema.TypeBool,
Required: true,
DefaultFunc: func() (interface{}, error) {
return false, nil
},
Description: "Okta API token",
},
},
ResourcesMap: map[string]*schema.Resource{
"okta_group": resourceGroup(),
"okta_membership": resourceMembership(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
// configure the okta client
client := okta.NewClient(
d.Get("token").(string),
d.Get("organization").(string),
d.Get("preview").(bool),
&http.Client{Timeout: 60 * time.Second},
)
return client, nil
}