bc10055edc
The importing peer will need to know what SNI and SPIFFE name corresponds to each exported service. Additionally it will need to know at a high level the protocol in use (L4/L7) to generate the appropriate connection pool and local metrics. For replicated connect synthetic entities we edit the `Connect{}` part of a `NodeService` to have a new section: { "PeerMeta": { "SNI": [ "web.default.default.owt.external.183150d5-1033-3672-c426-c29205a576b8.consul" ], "SpiffeID": [ "spiffe://183150d5-1033-3672-c426-c29205a576b8.consul/ns/default/dc/dc1/svc/web" ], "Protocol": "tcp" } } This data is then replicated and saved as-is at the importing side. Both SNI and SpiffeID are slices for now until I can be sure we don't need them for how mesh gateways will ultimately work.
249 lines
7.1 KiB
Go
249 lines
7.1 KiB
Go
// Code generated by mog. DO NOT EDIT.
|
|
|
|
package pbservice
|
|
|
|
import "github.com/hashicorp/consul/agent/structs"
|
|
|
|
func ConnectProxyConfigToStructs(s *ConnectProxyConfig, t *structs.ConnectProxyConfig) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.DestinationServiceName = s.DestinationServiceName
|
|
t.DestinationServiceID = s.DestinationServiceID
|
|
t.LocalServiceAddress = s.LocalServiceAddress
|
|
t.LocalServicePort = int(s.LocalServicePort)
|
|
t.LocalServiceSocketPath = s.LocalServiceSocketPath
|
|
t.Mode = structs.ProxyMode(s.Mode)
|
|
t.Config = ProtobufTypesStructToMapStringInterface(s.Config)
|
|
t.Upstreams = UpstreamsToStructs(s.Upstreams)
|
|
if s.MeshGateway != nil {
|
|
MeshGatewayConfigToStructs(s.MeshGateway, &t.MeshGateway)
|
|
}
|
|
if s.Expose != nil {
|
|
ExposeConfigToStructs(s.Expose, &t.Expose)
|
|
}
|
|
if s.TransparentProxy != nil {
|
|
TransparentProxyConfigToStructs(s.TransparentProxy, &t.TransparentProxy)
|
|
}
|
|
}
|
|
func ConnectProxyConfigFromStructs(t *structs.ConnectProxyConfig, s *ConnectProxyConfig) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.DestinationServiceName = t.DestinationServiceName
|
|
s.DestinationServiceID = t.DestinationServiceID
|
|
s.LocalServiceAddress = t.LocalServiceAddress
|
|
s.LocalServicePort = int32(t.LocalServicePort)
|
|
s.LocalServiceSocketPath = t.LocalServiceSocketPath
|
|
s.Mode = string(t.Mode)
|
|
s.Config = MapStringInterfaceToProtobufTypesStruct(t.Config)
|
|
s.Upstreams = NewUpstreamsFromStructs(t.Upstreams)
|
|
{
|
|
var x MeshGatewayConfig
|
|
MeshGatewayConfigFromStructs(&t.MeshGateway, &x)
|
|
s.MeshGateway = &x
|
|
}
|
|
{
|
|
var x ExposeConfig
|
|
ExposeConfigFromStructs(&t.Expose, &x)
|
|
s.Expose = &x
|
|
}
|
|
{
|
|
var x TransparentProxyConfig
|
|
TransparentProxyConfigFromStructs(&t.TransparentProxy, &x)
|
|
s.TransparentProxy = &x
|
|
}
|
|
}
|
|
func ExposeConfigToStructs(s *ExposeConfig, t *structs.ExposeConfig) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.Checks = s.Checks
|
|
t.Paths = ExposePathSliceToStructs(s.Paths)
|
|
}
|
|
func ExposeConfigFromStructs(t *structs.ExposeConfig, s *ExposeConfig) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.Checks = t.Checks
|
|
s.Paths = NewExposePathSliceFromStructs(t.Paths)
|
|
}
|
|
func ExposePathToStructs(s *ExposePath, t *structs.ExposePath) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.ListenerPort = int(s.ListenerPort)
|
|
t.Path = s.Path
|
|
t.LocalPathPort = int(s.LocalPathPort)
|
|
t.Protocol = s.Protocol
|
|
t.ParsedFromCheck = s.ParsedFromCheck
|
|
}
|
|
func ExposePathFromStructs(t *structs.ExposePath, s *ExposePath) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.ListenerPort = int32(t.ListenerPort)
|
|
s.Path = t.Path
|
|
s.LocalPathPort = int32(t.LocalPathPort)
|
|
s.Protocol = t.Protocol
|
|
s.ParsedFromCheck = t.ParsedFromCheck
|
|
}
|
|
func MeshGatewayConfigToStructs(s *MeshGatewayConfig, t *structs.MeshGatewayConfig) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.Mode = structs.MeshGatewayMode(s.Mode)
|
|
}
|
|
func MeshGatewayConfigFromStructs(t *structs.MeshGatewayConfig, s *MeshGatewayConfig) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.Mode = string(t.Mode)
|
|
}
|
|
func PeeringServiceMetaToStructs(s *PeeringServiceMeta, t *structs.PeeringServiceMeta) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.SNI = s.SNI
|
|
t.SpiffeID = s.SpiffeID
|
|
t.Protocol = s.Protocol
|
|
}
|
|
func PeeringServiceMetaFromStructs(t *structs.PeeringServiceMeta, s *PeeringServiceMeta) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.SNI = t.SNI
|
|
s.SpiffeID = t.SpiffeID
|
|
s.Protocol = t.Protocol
|
|
}
|
|
func ServiceConnectToStructs(s *ServiceConnect, t *structs.ServiceConnect) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.Native = s.Native
|
|
t.SidecarService = ServiceDefinitionPtrToStructs(s.SidecarService)
|
|
if s.PeerMeta != nil {
|
|
var x structs.PeeringServiceMeta
|
|
PeeringServiceMetaToStructs(s.PeerMeta, &x)
|
|
t.PeerMeta = &x
|
|
}
|
|
}
|
|
func ServiceConnectFromStructs(t *structs.ServiceConnect, s *ServiceConnect) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.Native = t.Native
|
|
s.SidecarService = NewServiceDefinitionPtrFromStructs(t.SidecarService)
|
|
if t.PeerMeta != nil {
|
|
var x PeeringServiceMeta
|
|
PeeringServiceMetaFromStructs(t.PeerMeta, &x)
|
|
s.PeerMeta = &x
|
|
}
|
|
}
|
|
func ServiceDefinitionToStructs(s *ServiceDefinition, t *structs.ServiceDefinition) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.Kind = structs.ServiceKind(s.Kind)
|
|
t.ID = s.ID
|
|
t.Name = s.Name
|
|
t.Tags = s.Tags
|
|
t.Address = s.Address
|
|
t.TaggedAddresses = MapStringServiceAddressToStructs(s.TaggedAddresses)
|
|
t.Meta = s.Meta
|
|
t.Port = int(s.Port)
|
|
t.SocketPath = s.SocketPath
|
|
if s.Check != nil {
|
|
CheckTypeToStructs(s.Check, &t.Check)
|
|
}
|
|
t.Checks = CheckTypesToStructs(s.Checks)
|
|
t.Weights = WeightsPtrToStructs(s.Weights)
|
|
t.Token = s.Token
|
|
t.EnableTagOverride = s.EnableTagOverride
|
|
t.Proxy = ConnectProxyConfigPtrToStructs(s.Proxy)
|
|
t.EnterpriseMeta = EnterpriseMetaToStructs(s.EnterpriseMeta)
|
|
t.Connect = ServiceConnectPtrToStructs(s.Connect)
|
|
}
|
|
func ServiceDefinitionFromStructs(t *structs.ServiceDefinition, s *ServiceDefinition) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.Kind = string(t.Kind)
|
|
s.ID = t.ID
|
|
s.Name = t.Name
|
|
s.Tags = t.Tags
|
|
s.Address = t.Address
|
|
s.TaggedAddresses = NewMapStringServiceAddressFromStructs(t.TaggedAddresses)
|
|
s.Meta = t.Meta
|
|
s.Port = int32(t.Port)
|
|
s.SocketPath = t.SocketPath
|
|
{
|
|
var x CheckType
|
|
CheckTypeFromStructs(&t.Check, &x)
|
|
s.Check = &x
|
|
}
|
|
s.Checks = NewCheckTypesFromStructs(t.Checks)
|
|
s.Weights = NewWeightsPtrFromStructs(t.Weights)
|
|
s.Token = t.Token
|
|
s.EnableTagOverride = t.EnableTagOverride
|
|
s.Proxy = NewConnectProxyConfigPtrFromStructs(t.Proxy)
|
|
s.EnterpriseMeta = NewEnterpriseMetaFromStructs(t.EnterpriseMeta)
|
|
s.Connect = NewServiceConnectPtrFromStructs(t.Connect)
|
|
}
|
|
func TransparentProxyConfigToStructs(s *TransparentProxyConfig, t *structs.TransparentProxyConfig) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.OutboundListenerPort = int(s.OutboundListenerPort)
|
|
t.DialedDirectly = s.DialedDirectly
|
|
}
|
|
func TransparentProxyConfigFromStructs(t *structs.TransparentProxyConfig, s *TransparentProxyConfig) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.OutboundListenerPort = int32(t.OutboundListenerPort)
|
|
s.DialedDirectly = t.DialedDirectly
|
|
}
|
|
func UpstreamToStructs(s *Upstream, t *structs.Upstream) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.DestinationType = s.DestinationType
|
|
t.DestinationNamespace = s.DestinationNamespace
|
|
t.DestinationPartition = s.DestinationPartition
|
|
t.DestinationPeer = s.DestinationPeer
|
|
t.DestinationName = s.DestinationName
|
|
t.Datacenter = s.Datacenter
|
|
t.LocalBindAddress = s.LocalBindAddress
|
|
t.LocalBindPort = int(s.LocalBindPort)
|
|
t.LocalBindSocketPath = s.LocalBindSocketPath
|
|
t.LocalBindSocketMode = s.LocalBindSocketMode
|
|
t.Config = ProtobufTypesStructToMapStringInterface(s.Config)
|
|
if s.MeshGateway != nil {
|
|
MeshGatewayConfigToStructs(s.MeshGateway, &t.MeshGateway)
|
|
}
|
|
t.CentrallyConfigured = s.CentrallyConfigured
|
|
}
|
|
func UpstreamFromStructs(t *structs.Upstream, s *Upstream) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.DestinationType = t.DestinationType
|
|
s.DestinationNamespace = t.DestinationNamespace
|
|
s.DestinationPartition = t.DestinationPartition
|
|
s.DestinationPeer = t.DestinationPeer
|
|
s.DestinationName = t.DestinationName
|
|
s.Datacenter = t.Datacenter
|
|
s.LocalBindAddress = t.LocalBindAddress
|
|
s.LocalBindPort = int32(t.LocalBindPort)
|
|
s.LocalBindSocketPath = t.LocalBindSocketPath
|
|
s.LocalBindSocketMode = t.LocalBindSocketMode
|
|
s.Config = MapStringInterfaceToProtobufTypesStruct(t.Config)
|
|
{
|
|
var x MeshGatewayConfig
|
|
MeshGatewayConfigFromStructs(&t.MeshGateway, &x)
|
|
s.MeshGateway = &x
|
|
}
|
|
s.CentrallyConfigured = t.CentrallyConfigured
|
|
}
|