forked from rework-space-com/terraform-provider-freeipa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
35 lines (28 loc) · 719 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
package main
import (
"crypto/tls"
"log"
"net/http"
ipa "github.com/RomanButsiy/go-freeipa/freeipa"
)
// Config is the configuration parameters for the FreeIPA API
type Config struct {
Host string
Username string
Password string
InsecureSkipVerify bool
}
// Client creates a FreeIPA client scoped to the global API
func (c *Config) Client() (*ipa.Client, error) {
tspt := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: c.InsecureSkipVerify,
},
}
client, err := ipa.Connect(c.Host, tspt, c.Username, c.Password)
if err != nil {
return nil, err
}
log.Printf("[INFO] FreeIPA Client configured for host: %s", c.Host)
return client, nil
}