-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclient.go
More file actions
31 lines (26 loc) · 764 Bytes
/
client.go
File metadata and controls
31 lines (26 loc) · 764 Bytes
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
package storage
import (
"github.com/deis/builder/pkg/sys"
s3 "github.com/minio/minio-go"
)
type Client struct {
*s3.Client
Endpoint *Endpoint
}
// GetClient returns a S3 API compatible storage client
func GetClient(regionStr string, fs sys.FS, env sys.Env) (*Client, error) {
auth, err := getAuth(fs)
if err != nil {
return nil, err
}
endpoint, err := getEndpoint(env)
if err != nil {
return nil, err
}
// the New function call guesses which signature version to use. Currently, it correctly guesses V2 for GCS and V4 for both AWS S3 and Minio
s3Client, err := s3.New(endpoint.URLStr, auth.accessKeyID, auth.accessKeySecret, !endpoint.Secure)
if err != nil {
return nil, err
}
return &Client{Client: s3Client, Endpoint: endpoint}, nil
}