return early if backendName is empty

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
This commit is contained in:
Mikkel Oscar Lyderik Larsen 2021-08-20 09:32:48 +02:00
parent a08860d06c
commit c618494177
No known key found for this signature in database
GPG Key ID: 50AD98B2A0D8D4EF

View File

@ -139,17 +139,17 @@ func getRouteGroupWeight(backends []rgv1.RouteGroupBackendReference, backendName
return 1.0, nil
}
if backendName == "" {
return 0.0, errBackendNameMissing
}
for _, backend := range backends {
if backend.BackendName == backendName {
return float64(backend.Weight) / 100.0, nil
}
}
if backendName != "" {
return 0.0, nil
}
return 0.0, errBackendNameMissing
}
// getCollector returns a collector for getting the metrics.