-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
56 lines (44 loc) · 1.08 KB
/
main.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
package main
import (
"flag"
"fmt"
"github.com/spf13/cast"
"github.com/spf13/viper"
"os"
"slack-redmine-bot/redmine"
"slack-redmine-bot/slack"
)
func configInit() {
viper.SetEnvPrefix("srb")
var configPath string
flag.StringVar(&configPath, "config", "", "Path of configuration file without name (name must be config.yml)")
flag.Parse()
if len(configPath) > 0 {
viper.AddConfigPath(configPath)
}
configPath = os.Getenv("SRB_CONFIG")
if len(configPath) > 0 {
viper.AddConfigPath(configPath)
}
viper.AddConfigPath("/etc/slack-redmine-bot/")
viper.AddConfigPath(".")
viper.SetConfigName("config")
viper.SetConfigType("yaml")
err := viper.ReadInConfig()
if err != nil {
panic(fmt.Errorf("Error in config file. %s \n", err))
}
}
func init() {
configInit()
}
func main() {
redmine := redmine.New(
viper.GetString("redmine.url"),
viper.GetString("redmine.api_key"),
cast.ToIntSlice(viper.Get("redmine.closed_statuses")),
cast.ToIntSlice(viper.Get("redmine.high_priorities")),
)
slack := slack.New(redmine, viper.GetString("slack.token"))
slack.Listen()
}