-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
34 lines (27 loc) · 861 Bytes
/
config.go
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
package common
import (
"os"
"github.com/rs/zerolog/log"
"gopkg.in/yaml.v2"
)
// OrchestratorConfiguration describe the business config of the server.
// Contrary to the technical conf item which are received as env var,
// some business details are passed as a yml config file.
type OrchestratorConfiguration struct {
// map of channels -> organizations
Channels map[string][]string `yaml:"channels"`
}
// Version represents the version of the server, the value is changed at build time
var Version = "dev"
func NewConfig(path string) *OrchestratorConfiguration {
conf := new(OrchestratorConfiguration)
yamlFile, err := os.ReadFile(path)
if err != nil {
log.Fatal().Err(err).Msg("Failed to read config file")
}
err = yaml.Unmarshal(yamlFile, conf)
if err != nil {
log.Fatal().Err(err).Msg("Failed to parse config file")
}
return conf
}