-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
62 lines (55 loc) · 1.89 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
package jumpcloud
import (
"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
// Provider instantiates a terraform provider for Jumpcloud
// This includes all operations on all supported resources and
// global Jumpcloud parameters
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"api_key": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("JUMPCLOUD_API_KEY", nil),
Description: descriptions["api_key"],
},
"org_id": {
Type: schema.TypeString,
Required: false,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("JUMPCLOUD_ORG_ID", nil),
Description: descriptions["org_id"],
},
},
ResourcesMap: map[string]*schema.Resource{
"jumpcloud_user": resourceUser(),
"jumpcloud_user_group": resourceUserGroup(),
"jumpcloud_user_group_membership": resourceUserGroupMembership(),
"jumpcloud_user_group_ldap_membership": resourceUserGroupLdapMembership(),
"jumpcloud_user_group_association": resourceUserGroupAssociation(),
"jumpcloud_system_group": resourceGroupsSystem(),
},
DataSourcesMap: map[string]*schema.Resource{
"jumpcloud_ldap_server": dataResourceLdapServer(),
"jumpcloud_application": dataSourceApplication(),
},
ConfigureContextFunc: providerConfigure,
}
}
var descriptions map[string]string
func init() {
descriptions = map[string]string{
"api_key": "The x-api-key header used to connect to JumpCloud.",
"org_id": "The x-org-id header used to connect to JumpCloud.",
}
}
func providerConfigure(_ context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) {
config := Config{
APIKey: d.Get("api_key").(string),
OrgID: d.Get("org_id").(string),
}
return config.Client(), nil
}