2023-11-02 21:13:16 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
|
|
package catalogv2
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/testing/deployer/topology"
|
|
|
|
)
|
|
|
|
|
2023-11-10 19:22:06 +00:00
|
|
|
// 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)
|
2023-11-02 21:13:16 +00:00
|
|
|
} else {
|
2023-11-10 19:22:06 +00:00
|
|
|
return strings.Join([]string{dest.ID.Name, dest.ID.Namespace, dest.Peer, "external"}, ".")
|
2023-11-02 21:13:16 +00:00
|
|
|
}
|
|
|
|
}
|
2023-11-08 23:20:00 +00:00
|
|
|
|
2023-11-10 19:22:06 +00:00
|
|
|
func clusterPrefix(port string, svcID topology.ID, cluster string) string {
|
2023-11-08 23:20:00 +00:00
|
|
|
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"}, ".")
|
|
|
|
}
|
|
|
|
}
|