feat(): initial untested implementation
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:"K8S_CILIUM_NODE_LABEL_LOGLEVEL"`
|
||||
CiliumLabel string `default:"cilium.uploadfilter24.eu/speaker" env:"K8S_CILIUM_NODE_LABEL_KEY"`
|
||||
DryRun bool `default:"false" env:"K8S_CILIUM_NODE_LABEL_DRY_RUN"`
|
||||
}
|
||||
|
||||
func GenConfig() (cfg *Config, err error) {
|
||||
|
||||
cfg = &Config{}
|
||||
|
||||
err = configor.New(&configor.Config{
|
||||
ENVPrefix: "K8S_CILIUM_NODE_LABEL",
|
||||
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