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.
consul/proto-public/pbcatalog/v2beta1/computed_failover_policy_ex...

49 lines
1.1 KiB

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package catalogv2beta1
import "github.com/hashicorp/consul/proto-public/pbresource"
// GetUnderlyingDestinations will collect FailoverDestinations from all
// internal fields and bundle them up in one slice.
//
// NOTE: no deduplication occurs.
func (x *ComputedFailoverPolicy) GetUnderlyingDestinations() []*FailoverDestination {
if x == nil {
return nil
}
estimate := 0
for _, pc := range x.PortConfigs {
estimate += len(pc.Destinations)
}
out := make([]*FailoverDestination, 0, estimate)
for _, pc := range x.PortConfigs {
out = append(out, pc.Destinations...)
}
return out
}
// GetUnderlyingDestinationRefs is like GetUnderlyingDestinations except it
// returns a slice of References.
//
// NOTE: no deduplication occurs.
func (x *ComputedFailoverPolicy) GetUnderlyingDestinationRefs() []*pbresource.Reference {
if x == nil {
return nil
}
dests := x.GetUnderlyingDestinations()
out := make([]*pbresource.Reference, 0, len(dests))
for _, dest := range dests {
if dest.Ref != nil {
out = append(out, dest.Ref)
}
}
return out
}