forked from yagilm/pingdom2stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.go
46 lines (43 loc) · 1.15 KB
/
configuration.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
package main
// Configuration options
type Configuration struct {
usermail string
pass string
headerXappkey string
// checkname string // name of the check, ex summary.average
checkid string // id of the check, aka, which domain are we checking
from int32
to int32
output string
mysqlurl string // mysql connection in DSN (Data Source Name)
pgurl string // postgres connection in DSN (Data Source Name)
pgschema string
inittable bool
addcheck bool
}
// Check if configuration is invalid
func (conf Configuration) configurationInvalid() bool {
if conf.inittable {
return conf.mysqlurl == "" && conf.pgurl == ""
}
if conf.addcheck {
return (conf.mysqlurl == "" && conf.pgurl == "") ||
conf.checkid == ""
}
return conf.usermail == "" ||
conf.pass == "" ||
conf.headerXappkey == "" ||
// conf.checkname == "" ||
conf.checkid == "" ||
conf.output == "" ||
(conf.mysqlurl != "" && conf.pgurl != "")
}
func (conf Configuration) selectdbsystem() (string, string) {
if conf.mysqlurl != "" {
return "mysql", conf.mysqlurl
}
if conf.pgurl != "" {
return "postgres", conf.pgurl
}
return "", ""
}