-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprovider.go
69 lines (61 loc) · 1.84 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
package bigfix
import (
"log"
"os"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
)
// Provider : Provider returns a terraform.ResourceProvider.
// Contains registry of Data sources and Resources
func Provider() terraform.ResourceProvider {
// actual provider
return &schema.Provider{
Schema: map[string]*schema.Schema{
"port": {
Type: schema.TypeString,
Required: true,
Description: "Bigfix server port number",
DefaultFunc: schema.EnvDefaultFunc("BFX_PORT", nil),
},
"username": {
Type: schema.TypeString,
Required: true,
Description: "Username of BES Console Operator Profile",
DefaultFunc: schema.EnvDefaultFunc("BFX_USERNAME", nil),
},
"password": {
Type: schema.TypeString,
Required: true,
Description: "Password of BES Console Operator Profile",
DefaultFunc: schema.EnvDefaultFunc("BFX_PASSWORD", nil),
},
"server": {
Type: schema.TypeString,
Required: true,
Description: "Bigfix server address",
DefaultFunc: schema.EnvDefaultFunc("BFX_SERVER", nil),
},
},
//Supported Data Sources by this provider
DataSourcesMap: map[string]*schema.Resource{
"bigfix_computer": dataSourceComputer(),
"bigfix_fixlet": dataSourceFixlet(),
},
//Supported Resources by this provider
ResourcesMap: map[string]*schema.Resource{
"bigfix_multiple_action_group": resourceMultiActionGroup(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config, err := BFXConfig(d)
log.Println("[DEBUG] mConfig on provider is ")
if err != nil {
log.Println("[ERROR] Failed to establish connection with BigFix server.")
os.Exit(1)
return nil, err
}
log.Println("[DEBUG] connecting to BigFix Server...")
return config, nil
}