forked from claudusd/terraform-windows-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
69 lines (63 loc) · 1.63 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 main
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/masterzen/winrm"
"strings"
)
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"host": {
Type: schema.TypeString,
Required: true,
Description: "Winrm Host",
},
"port": {
Type: schema.TypeInt,
Optional: true,
Default: 5986,
Description: "Winrm Port",
},
"endpoint": {
Type: schema.TypeString,
Optional: true,
Default: "/",
Description: "Winrm endpoint",
},
"username": {
Type: schema.TypeString,
Required: true,
Description: "Winrm username",
},
"password": {
Type: schema.TypeString,
Required: true,
Description: "Winrm password",
},
},
ResourcesMap: map[string]*schema.Resource{
"windowsnetwork_dhcp_mac_allowed": resourceMacAllow(),
"windowsnetwork_dhcp_reservation": resourceDHCPReservation(),
"windowsnetwork_dns_record_a": resourceRecordA(),
"windowsnetwork_dns_record_cname": resourceRecordCname(),
},
ConfigureFunc: providerConfigure,
}
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
endpoint := &winrm.Endpoint{
Host: d.Get("host").(string),
Port: d.Get("port").(int),
HTTPS: true,
Insecure: true,
}
communicator := &Communicator{
username: d.Get("username").(string),
password: d.Get("password").(string),
endpoint: endpoint,
}
return communicator, nil
}
func NormalizeMacWindows(mac string) string {
return strings.ToUpper(strings.Replace(mac, ":", "-", -1))
}