-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
55 lines (44 loc) · 1.11 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package s3
import (
"strings"
"github.com/k0kubun/pp"
"github.com/rai-project/config"
"github.com/rai-project/vipertags"
)
type s3Config struct {
Provider string `json:"provider" config:"store.provider" default:"s3"`
BaseURL string `json:"base_url" config:"store.base_url" default:"http://s3.amazonaws.com/rai-server/"`
Bucket string `json:"bucket" config:"store.bucket" default:"rai"`
ACL string `json:"acl" config:"store.acl" default:"public-read"`
done chan struct{} `json:"-" config:"-"`
}
var (
Config = &s3Config{
done: make(chan struct{}),
}
)
func (*s3Config) ConfigName() string {
return "S3"
}
func (a *s3Config) SetDefaults() {
vipertags.SetDefaults(a)
}
func (a *s3Config) Read() {
defer close(a.done)
vipertags.Fill(a)
if !strings.HasPrefix(a.BaseURL, "http://") && !strings.HasPrefix(a.BaseURL, "https://") {
a.BaseURL = "http://" + a.BaseURL
}
}
func (c s3Config) Wait() {
<-c.done
}
func (c *s3Config) String() string {
return pp.Sprintln(c)
}
func (c *s3Config) Debug() {
log.Debug("S3 Config = ", c)
}
func init() {
config.Register(Config)
}