Files
mark2web/pkg/mark2web/config_global.go
Sebastian Frank 5624c7af87
Some checks failed
continuous-integration/drone/push Build is failing
disable brotli support without CGO
2019-03-21 16:12:55 +01:00

57 lines
1.1 KiB
Go

package mark2web
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
// GlobalConfig is config which is used only once in root dir
type GlobalConfig struct {
Webserver struct {
Type string `yaml:"Type"`
} `yaml:"Webserver"`
Assets struct {
Compress bool `yaml:"Compress"`
FromPath string `yaml:"FromPath"`
ToPath string `yaml:"ToPath"`
Action string `yaml:"Action"`
FixTemplate struct {
Find string `yaml:"Find"`
Replace string `yaml:"Replace"`
} `yaml:"FixTemplate"`
} `yaml:"Assets"`
OtherFiles struct {
Action string `yaml:"Action"`
} `yaml:"OtherFiles"`
Compress struct {
Brotli bool `yaml:"Brotli"`
GZIP bool `yaml:"GZIP"`
Extensions map[string]string `yaml:"Extensions"`
} `yaml:"Compress"`
Directories struct {
Input string
Output string
}
}
// Config is global config
var Config = new(GlobalConfig)
// ReadFromFile reads yaml config from file
func (c *GlobalConfig) ReadFromFile(filename string) error {
data, err := ioutil.ReadFile(filename)
if err != nil {
return err
}
err = yaml.Unmarshal(data, c)
if err != nil {
return err
}
return nil
}