This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbotanist.go
57 lines (46 loc) · 1.41 KB
/
botanist.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"flag"
"io/ioutil"
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)
type config struct {
Hangouts HangoutsConfig
}
var botanistConfig = &config{}
var (
log = logrus.New()
configFileLocation *string
)
func main() {
verbose := flag.Bool("verbose", false, "Increase logging verbosity")
configFileLocation = flag.String("configFile", "botanist.conf", "Location of config file in YAML format")
flag.Parse()
configFile, err := ioutil.ReadFile(*configFileLocation)
if err != nil {
log.Fatalf("Error when trying to read config file at %s", *configFileLocation)
}
err = yaml.Unmarshal(configFile, botanistConfig)
if err != nil {
log.Fatalf("Error when parsing config file: %s", err)
}
log.Infoln("Botanist Starting.")
log.Infof("Configuration: Credentials File: %s, Project: %s, Subscription: %s.", botanistConfig.Hangouts.CredentialsFile, botanistConfig.Hangouts.Project, botanistConfig.Hangouts.PsSubscription)
if *verbose {
log.SetLevel(logrus.DebugLevel)
}
go startPrometheusListener()
// Actively load hangouts
// We should make this dependent on what's in the config file in the future
// and load only the messaging plattforms that are configured
initHangouts()
log.Infoln("Botanist Exiting.")
}
func persistConfigChanges() error {
data, err := yaml.Marshal(botanistConfig)
if err != nil {
return err
}
return ioutil.WriteFile(*configFileLocation, data, 0600)
}