Commit c3d0c1f6 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Add thorough checks for config values

parent b71a598b
......@@ -196,22 +196,39 @@ func getConfig(configFile string) (c config, err error) {
return
}
err = c.fetchConfig()
if err != nil {
log.Fatalf("[Conf] Error fetching remote config: %s", err)
return
// check the config values
if c.Host == "" {
log.Fatalf("[Conf] No 'host' in config")
}
if c.Username == "" {
log.Fatalf("[Conf] No 'user' in config")
}
if c.Password == "" {
log.Fatalf("[Conf] No 'password' in config")
}
if c.FetchIntervalString == "" {
log.Fatalf("[Conf] No 'fetch_interval' in config")
}
if c.ReconnectTimeoutString == "" {
log.Fatalf("[Conf] No 'reconnect_timeout' in config")
}
// parse som of the config values
if c.FetchInterval, err = time.ParseDuration(c.FetchIntervalString); err != nil {
log.Printf("[Conf] Error parsing fetch interval: %s", err)
return
}
log.Printf("[Conf] Fetch interval set to %s", c.FetchInterval)
if c.ReconnectTimeout, err = time.ParseDuration(c.ReconnectTimeoutString); err != nil {
log.Printf("[Conf] Error parsing reconnect timeout: %s", err)
return
}
log.Printf("[Conf] Reconnect timeout set to %s", c.ReconnectTimeout)
// fetch the remote configuration
err = c.fetchConfig()
if err != nil {
log.Fatalf("[Conf] Error fetching remote config: %s", err)
return
}
// initialize the task queues
c.NewTasks = make(chan task)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment