This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 277
/
service.go
44 lines (35 loc) · 1.6 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package catalog
import (
"github.com/openservicemesh/osm/pkg/identity"
"github.com/openservicemesh/osm/pkg/service"
)
// getServicesForServiceIdentity returns a list of services corresponding to a service identity
func (mc *MeshCatalog) getServicesForServiceIdentity(svcIdentity identity.ServiceIdentity) []service.MeshService {
var services []service.MeshService
for _, provider := range mc.serviceProviders {
providerServices := provider.GetServicesForServiceIdentity(svcIdentity)
log.Trace().Msgf("Found Services %v linked to Service Identity %s from provider %s", providerServices, svcIdentity, provider.GetID())
services = append(services, providerServices...)
}
return services
}
// ListServiceIdentitiesForService lists the service identities associated with the given mesh service.
func (mc *MeshCatalog) ListServiceIdentitiesForService(svc service.MeshService) []identity.ServiceIdentity {
// Currently OSM uses kubernetes service accounts as service identities
var serviceIdentities []identity.ServiceIdentity
for _, provider := range mc.serviceProviders {
serviceIDs := provider.ListServiceIdentitiesForService(svc)
serviceIdentities = append(serviceIdentities, serviceIDs...)
}
return serviceIdentities
}
// listMeshServices returns all services in the mesh
func (mc *MeshCatalog) listMeshServices() []service.MeshService {
var services []service.MeshService
for _, provider := range mc.serviceProviders {
svcs := provider.ListServices()
// TODO: handle duplicates when the codebase correctly supports multiple service providers
services = append(services, svcs...)
}
return services
}