-
Notifications
You must be signed in to change notification settings - Fork 26
/
config.go
36 lines (31 loc) · 890 Bytes
/
config.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
package aviatrix
import (
"crypto/tls"
"log"
"net/http"
"github.com/AviatrixSystems/go-aviatrix/goaviatrix"
)
// Config contains the configuration for the Aviatrix provider
// (Username, Password, and Controller IP)
type Config struct {
Username string
Password string
ControllerIP string
}
// Client gets the Aviatrix client to access the Controller
// Arguments:
// None
// Returns:
// the aviatrix client (from goaviatrix)
// error (if any)
func (c *Config) Client() (*goaviatrix.Client, error) {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client, err := goaviatrix.NewClient(c.Username, c.Password, c.ControllerIP, &http.Client{Transport: tr})
log.Printf("[INFO] Aviatrix Client configured for use")
if client == nil || err != nil {
log.Printf("[ERROR] unable to create client: %s", err)
}
return client, err
}