cleanup: standardize error format in util.GetTopologyFromDomainLabels()

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-12-08 15:25:10 +01:00 committed by mergify[bot]
parent 6d5de7458d
commit e3ea8ca0b1

View File

@ -53,7 +53,7 @@ func GetTopologyFromDomainLabels(domainLabels, nodeName, driverName string) (map
topologyPrefix := strings.ToLower("topology." + driverName) topologyPrefix := strings.ToLower("topology." + driverName)
const lenLimit = 63 const lenLimit = 63
if len(topologyPrefix) > lenLimit { if len(topologyPrefix) > lenLimit {
return nil, fmt.Errorf("computed topology label prefix (%s) for node exceeds length limits", topologyPrefix) return nil, fmt.Errorf("computed topology label prefix %q for node exceeds length limits", topologyPrefix)
} }
// driverName is validated, and we are adding a lowercase "topology." to it, so no validation for conformance // driverName is validated, and we are adding a lowercase "topology." to it, so no validation for conformance
@ -67,7 +67,7 @@ func GetTopologyFromDomainLabels(domainLabels, nodeName, driverName string) (map
// as we read the labels from k8s, and check for missing labels, // as we read the labels from k8s, and check for missing labels,
// no label conformance checks here // no label conformance checks here
if _, ok := labelsIn[label]; ok { if _, ok := labelsIn[label]; ok {
return nil, fmt.Errorf("duplicate label (%s) found in domain labels", label) return nil, fmt.Errorf("duplicate label %q found in domain labels", label)
} }
labelsIn[label] = true labelsIn[label] = true
@ -102,7 +102,7 @@ func GetTopologyFromDomainLabels(domainLabels, nodeName, driverName string) (map
missingLabels = append(missingLabels, key) missingLabels = append(missingLabels, key)
} }
} }
return nil, fmt.Errorf("missing domain labels %v on node (%s)", missingLabels, nodeName) return nil, fmt.Errorf("missing domain labels %v on node %q", missingLabels, nodeName)
} }
DefaultLog("list of domains processed: %+v", domainMap) DefaultLog("list of domains processed: %+v", domainMap)