forked from Huawei/DockerMachineDriver4OTC
-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.go
35 lines (31 loc) · 802 Bytes
/
client.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 common
import (
"crypto/tls"
"net"
"net/http"
"time"
)
type Client struct {
AccessKeyId string
AccessKeySecret string
HttpClient *http.Client
Endpoint string
Version string
}
var defaultTransport *http.Transport = &http.Transport{
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
}
func (client *Client) Init(version, endpoint, accessKeyId, accessKeySecret string) {
client.AccessKeyId = accessKeyId
client.AccessKeySecret = accessKeySecret
tlsConfig := tls.Config{}
tlsConfig.InsecureSkipVerify = true
defaultTransport.TLSClientConfig = &tlsConfig
client.HttpClient = &http.Client{Transport: defaultTransport}
client.Endpoint = endpoint
client.Version = version
}