2021-01-08 21:37:38 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/kelseyhightower/envconfig"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config keeps info about configuration of this daemon
|
|
|
|
type Config struct {
|
2021-01-09 21:32:52 +00:00
|
|
|
AppsPath string `envconfig:"APPS_PATH" default:"/srv"` // Where applications are located
|
|
|
|
AppsBindIP string `envconfig:"APPS_BIND_IP" default:"0.0.0.0"` // On what IP apps gonna be bound
|
2021-01-08 21:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetConfig return configuration created based on environment variables
|
|
|
|
func GetConfig() *Config {
|
|
|
|
var config Config
|
|
|
|
|
|
|
|
err := envconfig.Process("", &config)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
return &config
|
|
|
|
}
|