-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
51 lines (42 loc) · 1.21 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
package main
import (
"errors"
"os"
"github.com/BurntSushi/toml"
)
type crlConfig struct {
URL string `toml:"url"`
Name string `toml:"name"`
ProfileName string `toml:"profile_name"`
RefreshDelay duration `toml:"refresh_delay"`
Validate bool `toml:"validate"`
}
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_provided_name"`
}
type config struct {
F5 []f5Config `toml:"f5"`
CRL []crlConfig `toml:"crl"`
}
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
}
// hasCRLDistributionPoint reports whether the config defines at least one CRL
// distribution point.
func (c config) hasCRLDistributionPoint() bool {
return c.CRL != nil && len(c.CRL) > 0
}