2024-01-10 17:05:12 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2023-10-12 19:20:13 +00:00
|
|
|
package catalogv2beta1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"golang.org/x/exp/maps"
|
|
|
|
"golang.org/x/exp/slices"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetIdentities returns a list of unique identities that this service endpoints points to.
|
|
|
|
func (s *ServiceEndpoints) GetIdentities() []string {
|
|
|
|
uniqueIdentities := make(map[string]struct{})
|
|
|
|
|
|
|
|
for _, ep := range s.GetEndpoints() {
|
|
|
|
if ep.GetIdentity() != "" {
|
|
|
|
uniqueIdentities[ep.GetIdentity()] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(uniqueIdentities) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
identities := maps.Keys(uniqueIdentities)
|
|
|
|
slices.Sort(identities)
|
|
|
|
|
|
|
|
return identities
|
|
|
|
}
|