Cleanup
This commit is contained in:
parent
c5df325c98
commit
ffea85d397
1 changed files with 8 additions and 6 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue