Simplify Service Lookup
Since we already know the name and namespace of the service(s) we want we can just get the correct one back from the API without filtering the results.
This commit is contained in:
parent
e948a013cd
commit
6accb90c47
3 changed files with 41 additions and 54 deletions
|
@ -1212,14 +1212,13 @@ func (c clientMock) GetIngresses(predicate func(k8s.Ingress) bool) ([]k8s.Ingres
|
|||
func (c clientMock) WatchIngresses(predicate func(k8s.Ingress) bool, stopCh <-chan bool) (chan interface{}, chan error, error) {
|
||||
return c.watchChan, make(chan error), nil
|
||||
}
|
||||
func (c clientMock) GetServices(predicate func(k8s.Service) bool) ([]k8s.Service, error) {
|
||||
var services []k8s.Service
|
||||
func (c clientMock) GetService(name, namespace string) (k8s.Service, error) {
|
||||
for _, service := range c.services {
|
||||
if predicate(service) {
|
||||
services = append(services, service)
|
||||
if service.Namespace == namespace && service.Name == name {
|
||||
return service, nil
|
||||
}
|
||||
}
|
||||
return services, nil
|
||||
return k8s.Service{}, nil
|
||||
}
|
||||
|
||||
func (c clientMock) GetEndpoints(name, namespace string) (k8s.Endpoints, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue