changed configuration with default parameters
This commit is contained in:
parent
237f7a2907
commit
f702827034
33
functions.go
33
functions.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
@ -35,21 +36,27 @@ func GetConfig(configfile string, fuelpricesconfig *FuelPricesConfig) error {
|
||||
var fpc FuelPricesConfig
|
||||
|
||||
fuelpricesSection := config.Section("fuelprices")
|
||||
fpc.RemoteURL = fuelpricesSection.Key("remote_url").String()
|
||||
fpc.RemoteFilename = fuelpricesSection.Key("remote_filename").String()
|
||||
fpc.XPathBase = fuelpricesSection.Key("xpath_base").String()
|
||||
fpc.Table = fuelpricesSection.Key("table").String()
|
||||
fpc.RemoteURL = fuelpricesSection.Key("remote_url").MustString("https://donnees.roulez-eco.fr/opendata/instantane")
|
||||
fpc.RemoteFilename = fuelpricesSection.Key("remote_filename").MustString("PrixCarburants_instantane.xml")
|
||||
fpc.XPathBase = fuelpricesSection.Key("xpath_base").MustString(".//pdv[@id='%s']/prix[@nom='%s']")
|
||||
fpc.Table = fuelpricesSection.Key("table").MustString("fuel_price")
|
||||
fpc.Pos = fuelpricesSection.Key("pos").Strings(",")
|
||||
if len(fpc.Pos) < 1 {
|
||||
err := errors.New("No pos defined")
|
||||
return err
|
||||
}
|
||||
fpc.Types = fuelpricesSection.Key("types").Strings(",")
|
||||
if len(fpc.Types) < 1 {
|
||||
err := errors.New("No fuel types defined")
|
||||
return err
|
||||
}
|
||||
|
||||
influxdbSection := config.Section("influxdb")
|
||||
fpc.InfluxHost = influxdbSection.Key("hostname").String()
|
||||
fpc.InfluxPort, err = influxdbSection.Key("port").Int()
|
||||
fpc.InfluxUser = influxdbSection.Key("username").String()
|
||||
fpc.InfluxPass = influxdbSection.Key("password").String()
|
||||
|
||||
fpc.InfluxDB = influxdbSection.Key("database").String()
|
||||
|
||||
fpc.Pos = fuelpricesSection.Key("pos").Strings(",")
|
||||
fpc.Types = fuelpricesSection.Key("types").Strings(",")
|
||||
fpc.InfluxHost = influxdbSection.Key("hostname").MustString("localhost")
|
||||
fpc.InfluxPort = influxdbSection.Key("port").MustInt(8086)
|
||||
fpc.InfluxUser = influxdbSection.Key("username").MustString("username")
|
||||
fpc.InfluxPass = influxdbSection.Key("password").MustString("password")
|
||||
fpc.InfluxDB = influxdbSection.Key("database").MustString("me")
|
||||
|
||||
*fuelpricesconfig = fpc
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user