-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
46 lines (38 loc) · 1.01 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
package main
import "github.com/thomasgouveia/go-config"
type (
Config struct {
Server serverConfig `yaml:"server"`
Process processConfig `yaml:"process"`
}
serverConfig struct {
Port int `yaml:"port"`
LogLevel string `yaml:"logLevel"`
}
processConfig struct {
Command string `yaml:"command"`
DownstreamURL string `yaml:"downstreamUrl"`
}
)
var loaderOptions = &config.Options[Config]{
Format: config.YAML,
// Configure the loader to lookup for environment
// variables with the following pattern: ALPHA_*
EnvEnabled: true,
EnvPrefix: "alpha",
// Configure the loader to search for an alpha.yaml file
// inside one or more locations defined in `FileLocations`
FileName: "alpha",
FileLocations: []string{"/etc/alpha", "$HOME/.alpha", "."},
// Inject a default configuration in the loader
Default: &Config{
Server: serverConfig{
LogLevel: "INFO",
Port: 8080,
},
Process: processConfig{
Command: "",
DownstreamURL: "http://127.0.0.1:3000",
},
},
}