diff --git a/cmd/config-v8.go b/cmd/config-v8.go index b2660394..0cb99117 100644 --- a/cmd/config-v8.go +++ b/cmd/config-v8.go @@ -104,7 +104,7 @@ func loadConfigV8() (*configV8, *probe.Error) { cfgMutex.RLock() defer cfgMutex.RUnlock() - // Cached in private global variable. + // If already cached, return the cached value. if cacheCfgV8 != nil { return cacheCfgV8, nil } @@ -113,14 +113,24 @@ func loadConfigV8() (*configV8, *probe.Error) { return nil, errInvalidArgument().Trace() } - mcCfgV8, e := quick.Load(mustGetMcConfigPath(), newConfigV8()) - fatalIf(probe.NewError(e), "Unable to load mc config file ‘"+mustGetMcConfigPath()+"’.") + // Initialize a new config loader. + qc, e := quick.New(newConfigV8()) + if e != nil { + return nil, probe.NewError(e) + } - cfgV8 := mcCfgV8.Data().(*configV8) + // Load config at configPath, fails if config is not + // accessible, malformed or version missing. + if e = qc.Load(mustGetMcConfigPath()); e != nil { + return nil, probe.NewError(e) + } - // cache it. + cfgV8 := qc.Data().(*configV8) + + // Cache config. cacheCfgV8 = cfgV8 + // Success. return cfgV8, nil } diff --git a/cmd/config-validate.go b/cmd/config-validate.go index 91b3264c..c9476484 100644 --- a/cmd/config-validate.go +++ b/cmd/config-validate.go @@ -25,7 +25,7 @@ import ( // Check if version of the config is valid func validateConfigVersion(config *configV8) (bool, string) { if config.Version != globalMCConfigVersion { - return false, fmt.Sprintf("Config version %s does not match GlobalMCConfiguration %s.\n", + return false, fmt.Sprintf("Config version '%s' does not match mc config version '%s', please update your binary.\n", config.Version, globalMCConfigVersion) } return true, ""