36 lines
587 B
Go
36 lines
587 B
Go
package main
|
|
|
|
import (
|
|
"io/ioutil"
|
|
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type Config struct {
|
|
Settings ConfigSettings `yaml:"settings"`
|
|
Hooks []Hook `yaml:"hooks"`
|
|
}
|
|
|
|
type ConfigSettings struct {
|
|
BindAddress string // Bind address for the webserver
|
|
}
|
|
|
|
type Hook struct {
|
|
Name string
|
|
Route string
|
|
Command string
|
|
Background bool
|
|
}
|
|
|
|
func (cf *Config) SetDefaults() {
|
|
cf.Settings.BindAddress = ":2088"
|
|
}
|
|
|
|
func (cf *Config) LoadYAML(filename string) error {
|
|
content, err := ioutil.ReadFile(filename)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return yaml.Unmarshal(content, cf)
|
|
}
|