Skip to content

Commit

Permalink
Fail early
Browse files Browse the repository at this point in the history
  • Loading branch information
ADO committed May 24, 2017
1 parent f4a61c4 commit 6e2170f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions vsphere-influxdb.go
Expand Up @@ -706,15 +706,15 @@ func main() {
file, err := os.Open(*cfgFile)
if err != nil {
errlog.Println("Could not open configuration file", *cfgFile)
errlog.Println(err)
errlog.Fatalln(err)
}

jsondec := json.NewDecoder(file)
config := Configuration{}
err = jsondec.Decode(&config)
if err != nil {
errlog.Println("Could not decode configuration file", *cfgFile)
errlog.Println(err)
errlog.Fatalln(err)
}

for _, vcenter := range config.VCenters {
Expand All @@ -728,10 +728,11 @@ func main() {
})
if err != nil {
errlog.Println("Could not connect to InfluxDB")
errlog.Println(err)
} else {
stdlog.Println("Successfully connected to Influx")
errlog.Fatalln(err)
}

stdlog.Println("Successfully connected to Influx")

for _, vcenter := range config.VCenters {
queryVCenter(*vcenter, config, InfluxDBClient)
}
Expand Down

0 comments on commit 6e2170f

Please sign in to comment.