Skip to content

Commit

Permalink
sidecar-proxy refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
erichaberkorn committed May 15, 2023
1 parent 3967e33 commit be4a928
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions agent/sidecar_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions agent/structs/config_entry_exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions agent/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be4a928

Please sign in to comment.