Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
620 B

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
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
}