Logic error, move creation of map upwards

This commit is contained in:
Michael Schwarz
2026-06-22 16:01:49 +02:00
committed by Thomas Gruber
parent 9677a916be
commit 14d624fd22
+9 -9
View File
@@ -66,6 +66,15 @@ func (m *IpmiCollector) Init(config json.RawMessage) error {
} }
} }
// Read metrics to include
m.includeMetrics = make(map[string]bool)
for _, metric := range m.config.IncludeMetrics {
metric = strings.ToLower(strings.TrimSpace(metric))
if metric != "" {
m.includeMetrics[metric] = true
}
}
m.ipmitool = m.config.IpmitoolPath m.ipmitool = m.config.IpmitoolPath
m.ipmisensors = m.config.IpmisensorsPath m.ipmisensors = m.config.IpmisensorsPath
@@ -108,15 +117,6 @@ func (m *IpmiCollector) Init(config json.RawMessage) error {
m.ipmitool = "" m.ipmitool = ""
cclog.ComponentDebugf(m.name, "Unable to use ipmitool for ipmistat collector: %v", ipmiToolErr) cclog.ComponentDebugf(m.name, "Unable to use ipmitool for ipmistat collector: %v", ipmiToolErr)
// read metrics to include
m.includeMetrics = make(map[string]bool)
for _, metric := range m.config.IncludeMetrics {
metric = strings.ToLower(strings.TrimSpace(metric))
if metric != "" {
m.includeMetrics[metric] = true
}
}
return fmt.Errorf("unable to init neither ipmitool (%w) nor ipmi-sensors (%w)", ipmiToolErr, ipmiSensorsErr) return fmt.Errorf("unable to init neither ipmitool (%w) nor ipmi-sensors (%w)", ipmiToolErr, ipmiSensorsErr)
} }