-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
46 lines (39 loc) · 1.01 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
package main
import (
"crypto/x509"
"os"
)
// Config : configuration settings
type Config struct {
Username string
Password string
KibanaURL string
KibanaIndex string
KibanaFilter string
Insecure bool
Certificate string
CertificatePool *x509.CertPool
}
func getConfig() (config Config, err error) {
config.Username = os.Getenv("KIBANA_USERNAME")
config.Password = os.Getenv("KIBANA_PASSWORD")
config.KibanaURL = os.Getenv("KIBANA_URL")
config.KibanaIndex = os.Getenv("KIBANA_INDEX")
config.Certificate = os.Getenv("KIBANA_CERT")
config.KibanaFilter = os.Getenv("KIBANA_FILTER")
insecureString := os.Getenv("KIBANA_INSECURE")
if insecureString == "true" {
config.Insecure = true
} else {
config.Insecure = false
}
if config.Certificate != "" {
certificate, err := os.ReadFile(config.Certificate)
if err != nil {
return config, err
}
config.CertificatePool = x509.NewCertPool()
config.CertificatePool.AppendCertsFromPEM(certificate)
}
return config, err
}