2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 18:39:22 +00:00
|
|
|
|
2023-08-15 18:57:07 +00:00
|
|
|
package naming
|
2019-08-19 18:03:03 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
|
|
)
|
|
|
|
|
2023-08-15 18:57:07 +00:00
|
|
|
const (
|
|
|
|
// OriginalDestinationClusterName is the name we give to the passthrough
|
|
|
|
// cluster which redirects transparently-proxied requests to their original
|
|
|
|
// destination outside the mesh. This cluster prevents Consul from blocking
|
|
|
|
// connections to destinations outside of the catalog when in transparent
|
|
|
|
// proxy mode.
|
|
|
|
OriginalDestinationClusterName = "original-destination"
|
|
|
|
VirtualIPTag = "virtual"
|
|
|
|
)
|
|
|
|
|
2019-08-19 18:03:03 +00:00
|
|
|
func CustomizeClusterName(clusterName string, chain *structs.CompiledDiscoveryChain) string {
|
|
|
|
if chain == nil || chain.CustomizationHash == "" {
|
|
|
|
return clusterName
|
|
|
|
}
|
|
|
|
// Use a colon to delimit this prefix instead of a dot to avoid a
|
|
|
|
// theoretical collision problem with subsets.
|
|
|
|
return fmt.Sprintf("%s~%s", chain.CustomizationHash, clusterName)
|
|
|
|
}
|