-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathprovider.go
82 lines (71 loc) · 2.47 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package main
import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)
const (
providerDefaultEmptyString = "nil"
)
var (
descriptions map[string]string
)
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"api_url": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("IDENTITYNOW_URL", providerDefaultEmptyString),
Description: descriptions["api_url"],
},
"client_id": {
Type: schema.TypeString,
Optional: true,
Sensitive: true,
DefaultFunc: schema.EnvDefaultFunc("IDENTITYNOW_CLIENT_ID", providerDefaultEmptyString),
Description: descriptions["client_id"],
},
"client_secret": {
Type: schema.TypeString,
Optional: true,
Sensitive: true,
DefaultFunc: schema.EnvDefaultFunc("IDENTITYNOW_CLIENT_SECRET", providerDefaultEmptyString),
Description: descriptions["client_secret"],
},
},
ResourcesMap: map[string]*schema.Resource{
"identitynow_source": resourceSource(),
"identitynow_access_profile": resourceAccessProfile(),
"identitynow_role": resourceRole(),
"identitynow_account_aggregation_schedule": resourceScheduleAccountAggregation(),
"identitynow_account_schema_attribute": resourceAccountSchema(),
"identitynow_password_policy": resourcePasswordPolicy(),
},
DataSourcesMap: map[string]*schema.Resource{
"identitynow_source": dataSourceSource(),
"identitynow_access_profile": dataSourceAccessProfile(),
"identitynow_source_entitlement": dataSourceSourceEntitlement(),
"identitynow_identity": dataSourceIdentity(),
"identitynow_role": dataSourceRole(),
},
ConfigureFunc: providerConfigure,
}
}
func init() {
descriptions = map[string]string{
"api_url": "The URL to the IdentityNow API",
"client_id": "API client used to authenticate with the IdentityNow API",
"client_secret": "API client secret used to authenticate with the IdentityNow API",
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
apiURL := d.Get("api_url").(string)
clientId := d.Get("client_id").(string)
clientSecret := d.Get("client_secret").(string)
config := &Config{
URL: apiURL,
ClientId: clientId,
ClientSecret: clientSecret,
}
return config, nil
}