Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

catalog: Simplify GetServicesForServiceAccount() #1568

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better log messages
  • Loading branch information
Delyan Raychev committed Aug 19, 2020
commit 708df790fe6007e0b8336b745952a04eee0d5892
11 changes: 4 additions & 7 deletions pkg/catalog/service.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (
)

// GetServicesForServiceAccount returns a list of services corresponding to a service account
func (mc *MeshCatalog) GetServicesForServiceAccount(sa service.K8sServiceAccount) ([]service.MeshService, error) {
func (mc *MeshCatalog) GetServicesForServiceAccount(serviceAccount service.K8sServiceAccount) ([]service.MeshService, error) {
var services []service.MeshService
for _, provider := range mc.endpointsProviders {

@@ -15,15 +15,12 @@ func (mc *MeshCatalog) GetServicesForServiceAccount(sa service.K8sServiceAccount
continue
}

log.Trace().Msgf("[%s] Looking for Services for Name=%s", provider.GetID(), sa)
svc, err := provider.GetServiceForServiceAccount(sa)
if err != nil {
log.Warn().Msgf("Error getting services from provider %s: %s", provider.GetID(), err)
if svc, err := provider.GetServiceForServiceAccount(serviceAccount); err != nil {
log.Warn().Msgf("Error getting K8s Services linked to Service Account %s from provider %s: %s", provider.GetID(), serviceAccount, err)
} else {
log.Trace().Msgf("[%s] Found service %s for Name=%s", provider.GetID(), svc, sa)
log.Trace().Msgf("Found K8s Service %s linked to Service Account %s from endpoint provider %s", svc, serviceAccount, provider.GetID())
services = append(services, svc)
}

}

if len(services) == 0 {