frag-review/src/core/configuration.go
Matej Focko 25626f1f75
refactor: Improve error logging
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-07 00:25:29 +01:00

32 lines
755 B
Go

package core
import (
"os"
"gopkg.in/yaml.v2"
)
type Config struct {
Gitea struct {
InstanceURL string `yaml:"instance_url"`
Owner string `yaml:"owner"`
Repository string `yaml:"repository"`
Token string
} `yaml:"gitea"`
Language struct {
OnSeparateLine bool `yaml:"on_separate_line"`
Opening string `yaml:"opening"`
Continuation string `yaml:"continuation"`
Closing string `yaml:"closing"`
} `yaml:"language"`
}
func LoadConfig(config *Config, filename string) {
configFile, err := os.Open(filename)
ExitOnError("Couldn't open config file", err)
defer configFile.Close()
decoder := yaml.NewDecoder(configFile)
err = decoder.Decode(&config)
ExitOnError("Couldn't decode config file", err)
}