forked from romerojunior/cert-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
56 lines (46 loc) · 1.05 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 main
import (
"encoding/json"
"log"
"os"
)
// A `conf` represents the contents of the decoded `JSON` configuration file.
type conf struct {
Sources confSources
Destination confDestination
}
type confSources struct {
Filesystem confSourceFilesystem
F5 confSourceF5
}
type confDestination struct {
Aws confDestinationAws
}
type confSourceFilesystem struct {
ScanPaths []string
}
type confSourceF5 struct {
User string
Password string
URL string
Port int
}
type confDestinationAws struct {
Profile string
URL string
}
// loadConfig reads a configuration file (declared in `JSON` format) and decode
// its parameters intro a `conf` data type using a `JSON` decoder, it exits in
// case of failure while reading or decoding the configuration file.
func loadConfig(filepath string, c *conf) {
cf, err := os.Open(filepath)
if err != nil {
log.Fatal("error loading config: ", err)
}
defer cf.Close()
d := json.NewDecoder(cf)
err = d.Decode(c)
if err != nil {
log.Fatal("error decoding json config: ", err)
}
}