fix config handling

release/release-0.3.0
parent 86a8494292
commit 185da9660a
No known key found for this signature in database
GPG Key ID: 0B266738824CE0F0

@ -43,30 +43,24 @@ func config(configFile string) {
Config.UserId = viper.GetString("gridscale.userid")
Config.Token = viper.GetString("gridscale.token")
gsConfig := gsclient.DefaultConfiguration(Config.UserId, Config.Token)
Config.Client = gsclient.NewClient(gsConfig)
}
func main() {
var parser = flags.NewParser(&Checker, flags.Default)
if checkFileExistance("config/check.toml") {
config("config/check.toml")
}
if (os.Getenv("GRIDSCALE_USER") != "") && (os.Getenv("GRIDSCALE_TOKEN") != "") {
Config.UserId = os.Getenv("GRIDSCALE_USER")
Config.Token = os.Getenv("GRIDSCALE_TOKEN")
}
gsConfig := gsclient.DefaultConfiguration(Config.UserId, Config.Token)
gsConfig := gsclient.DefaultConfiguration(Config.UserId, Config.Token)
Config.Client = gsclient.NewClient(gsConfig)
Config.Client = gsclient.NewClient(gsConfig)
} else {
if checkFileExistance("config/check.toml") {
config("config/check.toml")
}
}
var parser = flags.NewParser(&Checker, flags.Default)
if _, err := parser.Parse(); err != nil {
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp {

Loading…
Cancel
Save