-
Notifications
You must be signed in to change notification settings - Fork 14
/
client.go
51 lines (42 loc) · 1005 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package goisilon
import (
"context"
"os"
"strconv"
"time"
"github.com/thecodeteam/goisilon/api"
)
// Client is an Isilon client.
type Client struct {
// API is the underlying OneFS API client.
API api.Client
}
func NewClient(ctx context.Context) (*Client, error) {
insecure, _ := strconv.ParseBool(os.Getenv("GOISILON_INSECURE"))
return NewClientWithArgs(
ctx,
os.Getenv("GOISILON_ENDPOINT"),
insecure,
os.Getenv("GOISILON_USERNAME"),
os.Getenv("GOISILON_GROUP"),
os.Getenv("GOISILON_PASSWORD"),
os.Getenv("GOISILON_VOLUMEPATH"))
}
func NewClientWithArgs(
ctx context.Context,
endpoint string,
insecure bool,
user, group, pass, volumesPath string) (*Client, error) {
timeout, _ := time.ParseDuration(os.Getenv("GOISILON_TIMEOUT"))
client, err := api.New(
ctx, endpoint, user, pass, group,
&api.ClientOptions{
Insecure: insecure,
VolumesPath: volumesPath,
Timeout: timeout,
})
if err != nil {
return nil, err
}
return &Client{client}, err
}