2017-09-17 03:26:19 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2018-01-13 14:41:49 +01:00
|
|
|
"io/ioutil"
|
2017-09-17 03:26:19 +02:00
|
|
|
|
2019-01-17 13:26:16 +01:00
|
|
|
"github.com/naoina/toml"
|
|
|
|
|
2017-09-17 03:26:19 +02:00
|
|
|
"github.com/FreifunkBremen/yanic/respond"
|
|
|
|
"github.com/FreifunkBremen/yanic/runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2018-01-19 04:31:33 +01:00
|
|
|
configPath string
|
|
|
|
collector *respond.Collector
|
|
|
|
nodes *runtime.Nodes
|
2017-09-17 03:26:19 +02:00
|
|
|
)
|
|
|
|
|
2018-01-13 14:41:49 +01:00
|
|
|
// ReadConfigFile reads a config model from path of a yml file
|
2019-01-24 02:54:21 +01:00
|
|
|
func ReadConfigFile(path string, config interface{}) error {
|
2018-01-13 14:41:49 +01:00
|
|
|
file, err := ioutil.ReadFile(path)
|
|
|
|
if err != nil {
|
2019-01-24 02:54:21 +01:00
|
|
|
return err
|
2018-01-13 14:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
err = toml.Unmarshal(file, config)
|
|
|
|
if err != nil {
|
2019-01-24 02:54:21 +01:00
|
|
|
return err
|
2018-01-13 14:41:49 +01:00
|
|
|
}
|
|
|
|
|
2019-01-24 02:54:21 +01:00
|
|
|
return nil
|
2018-01-13 14:41:49 +01:00
|
|
|
}
|