-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
40 lines (30 loc) · 830 Bytes
/
config.go
File metadata and controls
40 lines (30 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"io/ioutil"
"github.com/palantir/go-githubapp/githubapp"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
)
type Config struct {
Server HTTPConfig `yaml:"server"`
Github githubapp.Config `yaml:"github"`
AppConfig MyApplicationConfig `yaml:"app_configuration"`
}
type HTTPConfig struct {
Address string `yaml:"address"`
Port int `yaml:"port"`
}
type MyApplicationConfig struct {
PullRequestPreamble string `yaml:"pull_request_preamble"`
}
func ReadConfig(path string) (*Config, error) {
var c Config
bytes, err := ioutil.ReadFile(path)
if err != nil {
return nil, errors.Wrapf(err, "failed reading server config file: %s", path)
}
if err := yaml.UnmarshalStrict(bytes, &c); err != nil {
return nil, errors.Wrap(err, "failed parsing configuration file")
}
return &c, nil
}