-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
36 lines (31 loc) · 1.23 KB
/
options.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 gs
import (
"google.golang.org/api/option"
"github.com/hibrid/vfs/v6"
)
// Options holds Google Cloud Storage -specific options. Currently only client options are used.
type Options struct {
APIKey string `json:"apiKey,omitempty"`
CredentialFile string `json:"credentialFilePath,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
Scopes []string `json:"WithoutAuthentication,omitempty"`
Retry vfs.Retry
FileBufferSize int // Buffer Size In Bytes Used with utils.TouchCopyBuffered
}
func parseClientOptions(opts vfs.Options) []option.ClientOption {
var googleClientOpts []option.ClientOption
// we only care about 'gs.Options' types, skip anything else
if opts, ok := opts.(Options); ok {
switch {
case opts.APIKey != "":
googleClientOpts = append(googleClientOpts, option.WithAPIKey(opts.APIKey))
case opts.CredentialFile != "":
googleClientOpts = append(googleClientOpts, option.WithCredentialsFile(opts.CredentialFile))
case opts.Endpoint != "":
googleClientOpts = append(googleClientOpts, option.WithEndpoint(opts.Endpoint))
case len(opts.Scopes) > 0:
googleClientOpts = append(googleClientOpts, option.WithScopes(opts.Scopes...))
}
}
return googleClientOpts
}