This commit is contained in:
Manuel de Brito Fontes 2018-01-18 17:35:00 -03:00
parent c5df325c98
commit ffea85d397

View file

@ -30,11 +30,13 @@ type EndpointLister struct {
// GetServiceEndpoints returns the endpoints of a service, matched on service name. // GetServiceEndpoints returns the endpoints of a service, matched on service name.
func (s *EndpointLister) GetServiceEndpoints(svc *apiv1.Service) (*apiv1.Endpoints, error) { func (s *EndpointLister) GetServiceEndpoints(svc *apiv1.Service) (*apiv1.Endpoints, error) {
for _, m := range s.Store.List() { key := fmt.Sprintf("%v/%v", svc.Namespace, svc.Name)
ep := m.(*apiv1.Endpoints) eps, exists, err := s.GetByKey(key)
if svc.Name == ep.Name && svc.Namespace == ep.Namespace { if err != nil {
return ep, nil return nil, err
}
} }
return nil, fmt.Errorf("could not find endpoints for service: %v", svc.Name) if !exists {
return nil, fmt.Errorf("could not find endpoints for service %v", key)
}
return eps.(*apiv1.Endpoints), nil
} }