xds_cert: Fix walk on map
Since we know the key, no need to walk the map.
@@ -71,12 +71,10 @@ func GetPodFromCertificate(cn certificate.CommonName, kubecontroller k8s.Control
if pod.Namespace != cnMeta.Namespace {
continue
}
- for labelKey, labelValue := range pod.Labels {
- if labelKey == constants.EnvoyUniqueIDLabelName && labelValue == cnMeta.ProxyUUID.String() {
+ if uuid, labelFound := pod.Labels[constants.EnvoyUniqueIDLabelName]; labelFound && uuid == cnMeta.ProxyUUID.String() {
pods = append(pods, *pod)
}
}
- }
if len(pods) == 0 {
log.Error().Msgf("Did not find Pod with label %s = %s in namespace %s",
