-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathconfig.go
More file actions
39 lines (32 loc) · 1.19 KB
/
config.go
File metadata and controls
39 lines (32 loc) · 1.19 KB
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
package collectors
import "github.com/SUSE/connect-ng/pkg/profiles"
// defaultCollectorStates defines the default behavior per collector.
// true = opt-out (enabled by default), false = opt-in (disabled by default)
var defaultCollectorStates = map[string]bool{
"pci_devices": true,
"kernel_modules": true,
// Add other collectors here to define their default behavior
}
// DefaultCollectorState safely returns the default state for a given collector.
func DefaultCollectorState(collectorName string) bool {
if state, ok := defaultCollectorStates[collectorName]; ok {
return state
}
return false // Fallback if not found in defaults map
}
// CollectorOptions implements profiles.CollectorOptions interface
// This struct holds the actual collector configuration data
type CollectorOptions struct {
collectors map[string]profiles.CollectorConfig
}
func NewCollectorOptions(collectors map[string]profiles.CollectorConfig) *CollectorOptions {
return &CollectorOptions{
collectors: collectors,
}
}
func (c *CollectorOptions) IsCollectorEnabled(collectorName string) bool {
if config, ok := c.collectors[collectorName]; ok {
return config.Enabled
}
return DefaultCollectorState(collectorName)
}