-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_parser.go
70 lines (58 loc) · 1.36 KB
/
config_parser.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
package main
import (
gcfg "gopkg.in/gcfg.v1"
"log"
)
// MysqlConfig describes all possible MySQL configuration fields
type MysqlConfig struct {
OauthDB string
OauthSchemaPrefix string
Host string
Port string
User string
Password string
}
// LdapConfig describes all possible LDAP configuration fields
type LdapConfig struct {
BindDn string
BindPassword string
BindURL string
QueryDn string
GroupMemberQuery string
GroupBaseDN string
AttrSelectors []string
}
// OauthConfig describes all possible Oauth configuration fields
type OauthConfig struct {
StaticPath string
TemplatePath string
RouteStatic string
RouteLogin string
RouteToken string
RouteInfo string
}
// MattermostConfig describes all possible Mattermost configuration fields
type MattermostConfig struct {
URL string
Username string
Password string
UsernamePrefix string
}
// GeneralConfig describes all general configuration properties
type GeneralConfig struct {
ListenAddr string
}
type config struct {
Ldap LdapConfig
Mysql MysqlConfig
Oauth OauthConfig
Mattermost MattermostConfig
General GeneralConfig
}
func parseConfig(path string) (cfg config) {
err := gcfg.ReadFileInto(&cfg, path)
if err != nil {
log.Fatal(err)
}
return
}