forked from nyaruka/courier
-
Notifications
You must be signed in to change notification settings - Fork 2
/
courier.go
56 lines (40 loc) · 1.8 KB
/
courier.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
56
package config
import (
"github.com/koding/multiconfig"
)
// Courier is our top level configuration object
type Courier struct {
Backend string `default:"rapidpro"`
SentryDSN string `default:""`
BaseURL string `default:"https://localhost:8080"`
Port int `default:"8080"`
DB string `default:"postgres://courier@localhost/courier?sslmode=disable"`
Redis string `default:"redis://localhost:6379/0"`
SpoolDir string `default:"/var/spool/courier"`
S3Region string `default:"us-east-1"`
S3MediaBucket string `default:"courier-media"`
S3MediaPrefix string `default:"/media/"`
AWSAccessKeyID string `default:"missing_aws_access_key_id"`
AWSSecretAccessKey string `default:"missing_aws_secret_access_key"`
MaxWorkers int `default:"32"`
LibratoUsername string `default:""`
LibratoToken string `default:""`
StatusUsername string `default:""`
StatusPassword string `default:""`
RapidproHandleURL string `default:"https://app.rapidpro.io/handlers/mage/handle_message"`
RapidproToken string `default:"missing_rapidpro_token"`
LogLevel string `default:"error"`
IncludeChannels []string
ExcludeChannels []string
Version string `default:"Dev"`
}
// NewWithPath returns a new instance of Loader to read from the given configuration file using our config options
func NewWithPath(path string) *multiconfig.DefaultLoader {
loaders := []multiconfig.Loader{}
loaders = append(loaders, &multiconfig.TagLoader{})
loaders = append(loaders, &multiconfig.TOMLLoader{Path: path})
loaders = append(loaders, &multiconfig.EnvironmentLoader{CamelCase: true})
loaders = append(loaders, &multiconfig.FlagLoader{CamelCase: true})
loader := multiconfig.MultiLoader(loaders...)
return &multiconfig.DefaultLoader{Loader: loader, Validator: multiconfig.MultiValidator(&multiconfig.RequiredValidator{})}
}