forked from e-XpertSolutions/f5-auto-uploader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
42 lines (34 loc) · 928 Bytes
/
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
package main
import (
"errors"
"os"
"github.com/BurntSushi/toml"
)
type f5Config struct {
AuthMethod string `toml:"auth_method"`
URL string `toml:"url"`
User string `toml:"user"`
Password string `toml:"password"`
SSLCheck bool `toml:"ssl_check"`
LoginProviderName string `toml:"login_provider_name"`
}
type watchConfig struct {
Dir string `toml:"directory"`
Exclude []string `toml:"exclude"`
}
type config struct {
F5 f5Config `toml:"f5"`
Watch []watchConfig `toml:"watch"`
}
func readConfig(path string) (*config, error) {
file, err := os.Open(path)
if err != nil {
return nil, errors.New("cannot open configuration file: " + err.Error())
}
defer file.Close()
var cfg config
if _, err := toml.DecodeReader(file, &cfg); err != nil {
return nil, errors.New("cannot read configuration file: " + err.Error())
}
return &cfg, nil
}