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,13 +53,13 @@ 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
// Convert passed in labels to a map, and check for uniqueness // Convert passed in labels to a map, and check for uniqueness
labelsToRead := strings.SplitN(domainLabels, labelSeparator, -1) labelsToRead := strings.SplitN(domainLabels, labelSeparator, -1)
DefaultLog("passed in node labels for processing : %+v", labelsToRead) DefaultLog("passed in node labels for processing: %+v", labelsToRead)
labelsIn := make(map[string]bool) labelsIn := make(map[string]bool)
labelCount := 0 labelCount := 0
@ -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,10 +102,10 @@ 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)
topology := make(map[string]string) topology := make(map[string]string)
for domain, value := range domainMap { for domain, value := range domainMap {