forked from mozilla/tls-observatory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
56 lines (52 loc) · 1.12 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
package config
import (
"fmt"
"os"
"time"
"gopkg.in/gcfg.v1"
)
type Config struct {
General struct {
Enable bool
Postgres string
PostgresDB string
PostgresUser string
PostgresPass string
PostgresUseTLS bool
CipherscanPath string
ScanRefreshRate int
MaxProc int
Timeout time.Duration
}
TrustStores struct {
UbuntuTS string
MozillaTS string
MicrosoftTS string
AppleTS string
AndroidTS string
}
}
func Load(path string) (conf Config, err error) {
defer func() {
if e := recover(); e != nil {
err = fmt.Errorf("configLoad() -> %v", e)
}
}()
err = gcfg.ReadFileInto(&conf, path)
if err != nil {
panic(err)
}
if os.Getenv("TLSOBS_POSTGRES") != "" {
conf.General.Postgres = os.Getenv("TLSOBS_POSTGRES")
}
if os.Getenv("TLSOBS_POSTGRESDB") != "" {
conf.General.PostgresDB = os.Getenv("TLSOBS_POSTGRESDB")
}
if os.Getenv("TLSOBS_POSTGRESUSER") != "" {
conf.General.PostgresUser = os.Getenv("TLSOBS_POSTGRESUSER")
}
if os.Getenv("TLSOBS_POSTGRESPASS") != "" {
conf.General.PostgresPass = os.Getenv("TLSOBS_POSTGRESPASS")
}
return
}