-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.go
44 lines (40 loc) · 1.4 KB
/
environment.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
package config
import (
"github.com/spf13/viper"
)
//Values stores the current configuration values
var Values Config
//Config contains the application's configuration values. Add here your own variables and bind it on init() function
type Config struct {
//Port contains the port in which the application listens
Port string
//AppName for displaying in Monitoring
AppName string
//LogLevel - DEBUG or INFO or WARNING or ERROR or PANIC or FATAL
LogLevel string
//TestRun state if the current execution is a test execution
TestRun bool
// LocalTestRun state if the current execution is a test execution
LocalTestRun bool
//UsePrometheus to enable prometheus metrics endpoint
UsePrometheus bool
// EncodingRequest string used to authenticate requests
EncodingRequest string
}
func init() {
_ = viper.BindEnv("TestRun", "TESTRUN")
viper.SetDefault("TestRun", false)
_ = viper.BindEnv("LocalTestRun", "LOCALTESTRUN")
viper.SetDefault("LocalTestRun", false)
_ = viper.BindEnv("UsePrometheus", "USEPROMETHEUS")
viper.SetDefault("UsePrometheus", false)
_ = viper.BindEnv("Port", "PORT")
viper.SetDefault("Port", "8080")
_ = viper.BindEnv("AppName", "APP_NAME")
viper.SetDefault("AppName", ".")
_ = viper.BindEnv("LogLevel", "LOG_LEVEL")
viper.SetDefault("LogLevel", "INFO")
_ = viper.BindEnv("EncodingRequest", "ENCODING_REQUEST")
viper.SetDefault("EncodingRequest", "disabled")
_ = viper.Unmarshal(&Values)
}