feature/tt/initial-implementation (#1)
Reviewed-on: #1 Co-authored-by: Tobias Trabelsi <lerentis@uploadfilter24.eu> Co-committed-by: Tobias Trabelsi <lerentis@uploadfilter24.eu>
This commit is contained in:
30
internal/config.go
Normal file
30
internal/config.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/configor"
|
||||
)
|
||||
|
||||
type Config = struct {
|
||||
LogLevel string `default:"Info" env:"CANADA_KAKTUS_LOGLEVEL"`
|
||||
LabelSelector string `default:"kops.k8s.io/instance-role=Node" env:"CANADA_KAKTUS_LABELSELECTOR"`
|
||||
HcloudToken string `default:"" env:"CANADA_KAKTUS_HCLOUD_TOKEN"`
|
||||
}
|
||||
|
||||
func GenConfig() (cfg *Config, err error) {
|
||||
|
||||
cfg = &Config{}
|
||||
|
||||
err = configor.New(&configor.Config{
|
||||
ENVPrefix: "CANADA_KAKTUS",
|
||||
AutoReload: true,
|
||||
Silent: true,
|
||||
AutoReloadInterval: time.Minute}).Load(cfg, "config.json")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error generating Config: %s", err.Error())
|
||||
}
|
||||
return cfg, nil
|
||||
|
||||
}
|
Reference in New Issue
Block a user