diff --git a/agent/grpc-external/services/peerstream/subscription_manager.go b/agent/grpc-external/services/peerstream/subscription_manager.go index dea33a551fc..ec710e01758 100644 --- a/agent/grpc-external/services/peerstream/subscription_manager.go +++ b/agent/grpc-external/services/peerstream/subscription_manager.go @@ -744,7 +744,7 @@ func (m *subscriptionManager) NotifyStandardService( // // This name was chosen to match existing "sidecar service" generation logic // and similar logic in the Service Identity synthetic ACL policies. -const syntheticProxyNameSuffix = "-sidecar-proxy" +const syntheticProxyNameSuffix = structs.SidecarProxySuffix func generateProxyNameForDiscoveryChain(sn structs.ServiceName) structs.ServiceName { return structs.NewServiceName(sn.Name+syntheticProxyNameSuffix, &sn.EnterpriseMeta) diff --git a/agent/sidecar_service.go b/agent/sidecar_service.go index 3b536223ffb..6cd6d294e53 100644 --- a/agent/sidecar_service.go +++ b/agent/sidecar_service.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/consul/agent/structs" ) -const sidecarIDSuffix = "-sidecar-proxy" +const sidecarIDSuffix = structs.SidecarProxySuffix func sidecarIDFromServiceID(serviceID string) string { return serviceID + sidecarIDSuffix @@ -93,7 +93,7 @@ func sidecarServiceFromNodeService(ns *structs.NodeService, token string) (*stru sidecar.Kind = structs.ServiceKindConnectProxy } if sidecar.Service == "" { - sidecar.Service = ns.Service + "-sidecar-proxy" + sidecar.Service = ns.Service + structs.SidecarProxySuffix } if sidecar.Address == "" { // Inherit address from the service if it's provided diff --git a/agent/structs/config_entry_exports.go b/agent/structs/config_entry_exports.go index 81c62e1236d..958e6a24196 100644 --- a/agent/structs/config_entry_exports.go +++ b/agent/structs/config_entry_exports.go @@ -57,6 +57,7 @@ func (e *ExportedServicesConfigEntry) ToMap() map[string]map[string][]string { consumers = append(consumers, c.Partition) } resp[svc.Namespace][svc.Name] = consumers + resp[svc.Namespace][svc.Name+SidecarProxySuffix] = consumers } } return resp diff --git a/agent/structs/structs.go b/agent/structs/structs.go index c1728041a1f..3797751a381 100644 --- a/agent/structs/structs.go +++ b/agent/structs/structs.go @@ -1257,6 +1257,8 @@ func (a ServiceAddress) ToAPIServiceAddress() api.ServiceAddress { return api.ServiceAddress{Address: a.Address, Port: a.Port} } +const SidecarProxySuffix = "-sidecar-proxy" + // NodeService is a service provided by a node type NodeService struct { // Kind is the kind of service this is. Different kinds of services may