@@ -26,9 +26,11 @@ type Serialized struct {
26
26
Gather []string `json:"gather"`
27
27
EnableGlobalObfuscation bool `json:"enableGlobalObfuscation"`
28
28
OCM struct {
29
- SCAEndpoint string `json:"scaEndpoint"`
30
- SCAInterval string `json:"scaInterval"`
31
- SCADisabled bool `json:"scaDisabled"`
29
+ SCAEndpoint string `json:"scaEndpoint"`
30
+ SCAInterval string `json:"scaInterval"`
31
+ SCADisabled bool `json:"scaDisabled"`
32
+ ClusterTransferEndpoint string `json:"clusterTransferEndpoint"`
33
+ ClusterTransferInterval string `json:"clusterTransferInterval"`
32
34
}
33
35
}
34
36
@@ -75,9 +77,11 @@ type HTTPConfig struct {
75
77
76
78
// OCMConfig configures the interval and endpoint for retrieving the data from OCM API
77
79
type OCMConfig struct {
78
- SCAInterval time.Duration
79
- SCAEndpoint string
80
- SCADisabled bool
80
+ SCAInterval time.Duration
81
+ SCAEndpoint string
82
+ SCADisabled bool
83
+ ClusterTransferEndpoint string
84
+ ClusterTransferInterval time.Duration
81
85
}
82
86
83
87
type Converter func (s * Serialized , cfg * Controller ) (* Controller , error )
@@ -157,6 +161,13 @@ func (c *Controller) mergeOCM(cfg *Controller) {
157
161
c .OCMConfig .SCAInterval = cfg .OCMConfig .SCAInterval
158
162
}
159
163
c .OCMConfig .SCADisabled = cfg .OCMConfig .SCADisabled
164
+
165
+ if len (cfg .OCMConfig .ClusterTransferEndpoint ) > 0 {
166
+ c .OCMConfig .ClusterTransferEndpoint = cfg .OCMConfig .ClusterTransferEndpoint
167
+ }
168
+ if cfg .OCMConfig .ClusterTransferInterval > 0 {
169
+ c .OCMConfig .ClusterTransferInterval = cfg .OCMConfig .ClusterTransferInterval
170
+ }
160
171
}
161
172
162
173
func (c * Controller ) mergeHTTP (cfg * Controller ) {
@@ -171,11 +182,10 @@ func (c *Controller) mergeInterval(cfg *Controller) {
171
182
172
183
// ToController creates/updates a config Controller according to the Serialized config.
173
184
// Makes sure that the config is correct.
174
- func ToController (s * Serialized , cfg * Controller ) (* Controller , error ) { // nolint: gocyclo
185
+ func ToController (s * Serialized , cfg * Controller ) (* Controller , error ) { // nolint: gocyclo, funlen
175
186
if cfg == nil {
176
187
cfg = & Controller {}
177
188
}
178
-
179
189
cfg .Report = s .Report
180
190
cfg .StoragePath = s .StoragePath
181
191
cfg .Endpoint = s .Endpoint
@@ -252,6 +262,16 @@ func ToController(s *Serialized, cfg *Controller) (*Controller, error) { // noli
252
262
}
253
263
cfg .OCMConfig .SCAInterval = i
254
264
}
265
+ if len (s .OCM .SCAEndpoint ) > 0 {
266
+ cfg .OCMConfig .ClusterTransferEndpoint = s .OCM .ClusterTransferEndpoint
267
+ }
268
+ if len (s .OCM .ClusterTransferInterval ) > 0 {
269
+ i , err := time .ParseDuration (s .OCM .ClusterTransferInterval )
270
+ if err != nil {
271
+ return nil , fmt .Errorf ("OCM Cluster transfer interval must be a valid duration: %v" , err )
272
+ }
273
+ cfg .OCMConfig .ClusterTransferInterval = i
274
+ }
255
275
return cfg , nil
256
276
}
257
277
0 commit comments