refactored config names

This commit is contained in:
Paul 2019-06-15 13:55:48 +02:00
parent 4659714626
commit 0083207235
4 changed files with 17 additions and 14 deletions

View File

@ -8,10 +8,12 @@ xpath_base=.//pdv[@id='%s']/prix[@nom='%s']
# Comma separated values for pos and types
pos=50000007
types=Gazole,SP95,SP98
table=fuel_price
[influxdb]
# Influxdb settings
influx_host=host
influx_db=me
influx_port=8086
influx_user=influx
influx_pass=password
hostname=host
database=me
port=8086
username=influx
password=password

View File

@ -54,7 +54,7 @@ func main() {
fields := map[string]interface{}{"value": p.Amount}
point, _ := client.NewPoint(
fpc.InfluxTable,
fpc.Table,
tags,
fields,
now,

View File

@ -33,15 +33,17 @@ func GetConfig(configfile string, fuelpricesconfig *FuelPricesConfig) error {
fpc.RemoteURL = fuelpricesSection.Key("remote_url").String()
fpc.RemoteFilename = fuelpricesSection.Key("remote_filename").String()
fpc.XPathBase = fuelpricesSection.Key("xpath_base").String()
fpc.InfluxHost = fuelpricesSection.Key("influx_host").String()
fpc.InfluxPort, err = fuelpricesSection.Key("influx_port").Int()
fpc.Table = fuelpricesSection.Key("table").String()
influxdbSection := config.Section("influxdb")
fpc.InfluxHost = influxdbSection.Key("hostname").String()
fpc.InfluxPort, err = influxdbSection.Key("port").Int()
HandleError(err)
fpc.InfluxUser = fuelpricesSection.Key("influx_user").String()
fpc.InfluxPass = fuelpricesSection.Key("influx_pass").String()
fpc.InfluxUser = influxdbSection.Key("username").String()
fpc.InfluxPass = influxdbSection.Key("password").String()
HandleError(err)
fpc.InfluxDB = fuelpricesSection.Key("influx_db").String()
fpc.InfluxTable = fuelpricesSection.Key("influx_table").String()
fpc.InfluxDB = influxdbSection.Key("database").String()
fpc.Pos = fuelpricesSection.Key("pos").Strings(",")
fpc.Types = fuelpricesSection.Key("types").Strings(",")

View File

@ -19,13 +19,12 @@ type FuelPricesConfig struct {
XPathBase string
Pos []string
Types []string
TmpDir string
Table string
InfluxHost string
InfluxPort int
InfluxUser string
InfluxPass string
InfluxDB string
InfluxTable string
}
// Price contains price of points of sale