This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
/
provider.go
65 lines (60 loc) · 1.94 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
package graylog
import (
"github.com/hashicorp/terraform/helper/schema"
)
// Provider returns a terraform resource provider for graylog.
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"web_endpoint_uri": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"GRAYLOG_WEB_ENDPOINT_URI"}, nil),
},
"auth_name": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GRAYLOG_AUTH_NAME"}, nil),
},
"auth_password": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GRAYLOG_AUTH_PASSWORD"}, nil),
},
"x_requested_by": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GRAYLOG_X_REQUESTED_BY"}, "terraform-go-graylog"),
},
},
ResourcesMap: map[string]*schema.Resource{
"graylog_alert_condition": resourceAlertCondition(),
"graylog_alarm_callback": resourceAlarmCallback(),
"graylog_dashboard": resourceDashboard(),
"graylog_index_set": resourceIndexSet(),
"graylog_input": resourceInput(),
"graylog_ldap_setting": resourceLDAPSetting(),
"graylog_pipeline_rule": resourcePipelineRule(),
"graylog_role": resourceRole(),
"graylog_stream": resourceStream(),
"graylog_stream_rule": resourceStreamRule(),
"graylog_user": resourceUser(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := Config{
Endpoint: d.Get("web_endpoint_uri").(string),
AuthName: d.Get("auth_name").(string),
AuthPassword: d.Get("auth_password").(string),
XRequestedBy: d.Get("x_requested_by").(string),
}
if err := config.loadAndValidate(); err != nil {
return nil, err
}
return &config, nil
}