/
utils.go
51 lines (43 loc) · 1.36 KB
/
utils.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 utils
import (
"os"
"strconv"
"strings"
uberrors "github.com/IBM/ubiquity-k8s/utils/errors"
"github.com/IBM/ubiquity/resources"
)
func LoadConfig() (resources.UbiquityPluginConfig, error) {
config := resources.UbiquityPluginConfig{}
config.LogLevel = os.Getenv("LOG_LEVEL")
LogRotateMaxSize, err := strconv.Atoi(os.Getenv("FLEX_LOG_ROTATE_MAXSIZE"))
if err != nil {
if LogRotateMaxSize == 0 {
LogRotateMaxSize = 50
} else {
return config, err
}
}
config.LogRotateMaxSize = LogRotateMaxSize
config.LogPath = os.Getenv("LOG_PATH")
config.Backends = strings.Split(os.Getenv("BACKENDS"), ",")
ubiquity := resources.UbiquityServerConnectionInfo{}
port, err := strconv.ParseInt(os.Getenv("UBIQUITY_PORT"), 0, 32)
if err != nil {
return config, err
}
ubiquity.Port = int(port)
ubiquity.Address = os.Getenv("UBIQUITY_ADDRESS")
config.UbiquityServer = ubiquity
spectrumNFSConfig := resources.SpectrumNfsRemoteConfig{}
spectrumNFSConfig.ClientConfig = os.Getenv("SPECTRUM_NFS_REMOTE_CONFIG")
config.SpectrumNfsRemoteConfig = spectrumNFSConfig
config.CredentialInfo = resources.CredentialInfo{UserName: os.Getenv("UBIQUITY_USERNAME"), Password: os.Getenv("UBIQUITY_PASSWORD")}
return config, nil
}
func GetCurrentNamespace() (string, error) {
ns := os.Getenv(ENVNamespace)
if ns == "" {
return "", uberrors.ENVNamespaceNotSet
}
return ns, nil
}