-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
37 lines (33 loc) · 873 Bytes
/
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
package main
import (
"fmt"
"github.com/caarlos0/env/v6"
)
type config struct {
S3 configS3 `envPrefix:"S3_"`
GeoIP configGeoIP `envPrefix:"GEOIP_"`
}
type configS3 struct {
Endpoint string `env:"ENDPOINT"`
Region string `env:"REGION"`
ForcePathStyle bool `env:"FORCE_PATH_STYLE"`
Credentials configS3Credential `envPrefix:"CREDENTIAL_"`
Bucket string `env:"BUCKET"`
}
type configS3Credential struct {
KeyID string `env:"ACCESS_KEY_ID"`
SecretKey string `env:"SECRET_ACCESS_KEY"`
}
type configGeoIP struct {
CityDBPath string `env:"CITY_DB_PATH"`
}
func newConfig() (*config, error) {
cfg := config{}
err := env.Parse(&cfg, env.Options{
Prefix: "HTTPMSG_ENRICHER_",
})
if err != nil {
return nil, fmt.Errorf("Error parsing config: %w", err)
}
return &cfg, nil
}