consul/test-integ/catalogv2/helpers_test.go
R.B. Boyer b2979f6edf
testing/deployer: rename various terms to better align with v2 and avoid confusion (#19600)
Conceptually renaming the following topology terms to avoid confusion with v2 and to better align with it:

- ServiceID -> ID
- Service -> Workload
- Upstream -> Destination
2023-11-10 13:22:06 -06:00

32 lines
931 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package catalogv2
import (
"strings"
"github.com/hashicorp/consul/testing/deployer/topology"
)
// Deprecated: clusterPrefixForDestination
func clusterPrefixForUpstream(dest *topology.Destination) string {
return clusterPrefixForDestination(dest)
}
func clusterPrefixForDestination(dest *topology.Destination) string {
if dest.Peer == "" {
return clusterPrefix(dest.PortName, dest.ID, dest.Cluster)
} else {
return strings.Join([]string{dest.ID.Name, dest.ID.Namespace, dest.Peer, "external"}, ".")
}
}
func clusterPrefix(port string, svcID topology.ID, cluster string) string {
if svcID.PartitionOrDefault() == "default" {
return strings.Join([]string{port, svcID.Name, svcID.Namespace, cluster, "internal"}, ".")
} else {
return strings.Join([]string{port, svcID.Name, svcID.Namespace, svcID.Partition, cluster, "internal-v1"}, ".")
}
}