-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
99 lines (82 loc) · 2.65 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package app
import (
"io/ioutil"
"github.com/hairizuanbinnoorazman/techmeetup/eventstore"
"gopkg.in/yaml.v2"
)
type ConfigStore interface {
Get() (Config, error)
}
func NewBasicConfigStore(f string) BasicConfigStore {
return BasicConfigStore{
Filename: f,
}
}
type BasicConfigStore struct {
Filename string
}
func (b BasicConfigStore) Get() (Config, error) {
raw, err := ioutil.ReadFile(b.Filename)
if err != nil {
return Config{}, err
}
var a Config
err = yaml.Unmarshal(raw, &a)
if err != nil {
return Config{}, err
}
return a, nil
}
type Config struct {
Authstore string `yaml:"authstore"`
EventStoreFile string `yaml:"eventstore"`
Features Features `yaml:"features"`
Meetup MeetupCredentials `yaml:"meetup_credentials"`
Google GoogleCredentials `yaml:"google_credentials"`
Streamyard StreamyardCredentials `yaml:"streamyard_credentials"`
SpreadsheetStats string `yaml:"spreadsheet_stats"`
CalendarConfig CalendarConfig `yaml:"calendar_config"`
MeetupConfig MeetupConfig `yaml:"meetup_config"`
StreamyardConfig StreamyardConfig `yaml:"streamyard_config"`
}
type Features struct {
MeetupSync MeetupFeatureControl `yaml:"meetup_sync"`
AuthRefresh FeatureControl `yaml:"auth_refresh"`
}
type FeatureControl struct {
Enabled bool `yaml:"enabled"`
IdleDuration int `yaml:"idle_duration"`
}
type MeetupFeatureControl struct {
Enabled bool `yaml:"enabled"`
IdleDuration int `yaml:"idle_duration"`
SubFeatures eventstore.SubMeetupFeatureControl `yaml:"subfeatures"`
}
type MeetupCredentials struct {
ClientID string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
RedirectURI string `yaml:"redirect_uri"`
}
type GoogleCredentials struct {
ClientID string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
Scope string `yaml:"scope"`
RedirectURI string `yaml:"redirect_uri"`
}
type StreamyardCredentials struct {
CSRFToken string `yaml:"csrf_token"`
JWT string `yaml:"jwt"`
}
type CalendarConfig struct {
CalendarID string `yaml:"calendar_id"`
CalendarEventInvitation string `yaml:"calendar_event_invitation"`
}
type MeetupConfig struct {
MeetupGroup string `yaml:"meetup_group"`
OrganizerMapping map[string]string `yaml:"organizer_mapping"`
}
type StreamyardConfig struct {
UserID string `yaml:"user_id"`
YoutubeDestination string `yaml:"youtube_destination"`
FacebookGroupDestination string `yaml:"facebook_group_destination"`
}