Archived
1

Using flagger for config path getting

So, now we can deploy via go get and handle config in separate folder.
This commit is contained in:
2017-11-22 16:32:10 +04:00
parent dfe0d08ecc
commit ef9ba0310c
4 changed files with 63 additions and 26 deletions

View File

@@ -6,10 +6,11 @@ package config
import (
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
"lab.pztrn.name/golibs/mogrus"
"path/filepath"
)
// VERSION is the urrent bot's version
const VERSION = "0.51"
// DatabaseConnection handles database connection settings in config.yaml
@@ -45,11 +46,13 @@ type Config struct {
}
// Init is a configuration initializer
func (c *Config) Init() {
fname, _ := filepath.Abs("./config.yml")
func (c *Config) Init(log *mogrus.LoggerHandler, configPath string) {
fname, _ := filepath.Abs(configPath)
yamlFile, yerr := ioutil.ReadFile(fname)
if yerr != nil {
log.Fatal("Can't read config file")
} else {
log.Info("Using " + configPath + " as config file.")
}
yperr := yaml.Unmarshal(yamlFile, c)