Skip to content

Commit

Permalink
Merge pull request #11 from EladLeev/config-path
Browse files Browse the repository at this point in the history
Adding support for a custom config file
  • Loading branch information
EladLeev authored Oct 4, 2020
2 parents ca1c783 + 4fe64ec commit cceb5a1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion util/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package util

import (
"flag"

"github.com/BurntSushi/toml"
log "github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -39,8 +41,13 @@ func init() {
// initConfig load the config from path, parse it and return TomlConfig
func initConfig() TomlConfig {
log.Debug("Config init")
// Parse the user input for a configuration file
configPath := flag.String("config", "/opt/kcm/kcm.toml", "Absolute path to the configuration file")
flag.Parse()
log.Infof("Starting from config file:%v", *configPath)

var config TomlConfig
if _, err := toml.DecodeFile("/opt/kcm/kcm.toml", &config); err != nil {
if _, err := toml.DecodeFile(*configPath, &config); err != nil {
log.Panicf("Unble to load config file.\n%v", err)
}
// Set custom defaults
Expand Down

0 comments on commit cceb5a1

Please sign in to comment.