-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
47 lines (38 loc) · 1.29 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"io/ioutil"
"log"
"os"
"gopkg.in/yaml.v2"
)
// Config main config file structure
type Config struct {
SlackToken string `yaml:"slack_token"`
Port int `yaml:"port"`
SlackWebookURL string `yaml:"slack_webhook_url"`
Channel string `yaml:"channel"`
Database string `yaml:"database"`
SlackCommandToken string `yaml:"slack_command_token"`
AssetPath string `yaml:"asset_path"`
CalendarID string `yaml:"calendar_id"`
FullCalendarID string `yaml:"full_calendar_id"`
CalendarSecret string `yaml:"calendar_secret"`
CalendarCredentials string `yaml:"calendar_credentials"`
AnniversariesSheetCredentials string `yaml:"anniversaries_sheet_credentials"`
AnniversariesSheetId string `yaml:"anniversaries_sheet_id"`
TemplatesPath string `yaml:"templates_path"`
}
var config Config
func readConfig() {
if len(os.Args) < 2 {
log.Fatal("Missing required config parameter")
}
contents, err := ioutil.ReadFile(os.Args[1])
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(contents, &config)
if err != nil {
log.Fatalf("Error parsing config: %v", err)
}
}