-
Notifications
You must be signed in to change notification settings - Fork 6
/
config.go
95 lines (81 loc) · 2.56 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package testutils
import (
// get auth clients for gcp
"encoding/json"
"fmt"
"log"
"path/filepath"
"github.com/blackducksoftware/synopsysctl/pkg/util"
)
// TestConfig ...
var TestConfig = LoadTestConfig()
// AlertTestConfig ...
type AlertTestConfig struct {
Version string `json:"version"`
AppResourcesPath string `json:"appResourcesPath"`
}
// BDBATestConfig ...
type BDBATestConfig struct {
Version string `json:"version"`
AppResourcesPath string `json:"appResourcesPath"`
}
// BlackDuckTestConfig ...
type BlackDuckTestConfig struct {
Version string `json:"version"`
AppResourcesPath string `json:"appResourcesPath"`
Registry string `json:"registry"`
TLSCertPath string `json:"tlsCertPath"`
TLSKeyPath string `json:"tlsKeyPath"`
}
// OpsSightTestConfig ...
type OpsSightTestConfig struct {
Version string `json:"version"`
AppResourcesPath string `json:"appResourcesPath"`
}
// PolarisTestConfig ...
type PolarisTestConfig struct {
Version string `json:"version"`
AppResourcesPath string `json:"appResourcesPath"`
}
// PolarisReportingTestConfig ...
type PolarisReportingTestConfig struct {
Version string `json:"version"`
AppResourcesPath string `json:"appResourcesPath"`
ServiceAccountPath string `json:"serviceAccountPath"`
}
// TestConfigStruct ...
type TestConfigStruct struct {
// Config
AbsolutePathToTestSuite string `json:"absolutePathToTestSuite"`
// Synopsysctl
SynopsysctlPath string `json:"synopsysctlPath"`
SynopsysctlOperatorPath string `json:"synopsyctlOperatorPath"`
// App Configs
Alert AlertTestConfig `json:"alert"`
BDBA BDBATestConfig `json:"bdba"`
BlackDuck BlackDuckTestConfig `json:"blackDuck"`
OpsSight OpsSightTestConfig `json:"opsSight"`
Polaris PolarisTestConfig `json:"polaris"`
PolarisReporting PolarisReportingTestConfig `json:"polarisReporting"`
}
// LoadTestConfig ...
func LoadTestConfig() TestConfigStruct {
tc := TestConfigStruct{}
// TODO - make this better
for _, pth := range []string{"../", "../../", "../../../", "../../../../", "../../../../../"} {
configFilePath := fmt.Sprintf("%sconfig.json", pth)
data, err := util.ReadFileData(configFilePath)
if err != nil {
continue
}
err = json.Unmarshal([]byte(data), &tc)
if err != nil {
log.Fatalf("failed to unmarshal test config: %+v", err)
}
absPath, _ := filepath.Abs(pth)
tc.AbsolutePathToTestSuite = absPath
return tc
}
log.Fatal("failed to read config file")
return tc
}