Browse Source

copy peering with merge

Signed-off-by: acpana <8968914+acpana@users.noreply.github.com>
acpana/clean-peer-2
acpana 2 years ago
parent
commit
c4ce1be205
No known key found for this signature in database
GPG Key ID: 21CC0F2B42CEA01D
  1. 28
      agent/rpc/peering/service.go

28
agent/rpc/peering/service.go

@ -13,6 +13,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
grpcstatus "google.golang.org/grpc/status" grpcstatus "google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/acl"
"github.com/hashicorp/consul/agent/consul/state" "github.com/hashicorp/consul/agent/consul/state"
@ -610,22 +611,13 @@ func (s *Server) getExistingOrCreateNewPeerID(peerName, partition string) (strin
} }
func copyPeeringWith(p *pbpeering.Peering, state pbpeering.PeeringState, isc, esc uint64) *pbpeering.Peering { func copyPeeringWith(p *pbpeering.Peering, state pbpeering.PeeringState, isc, esc uint64) *pbpeering.Peering {
return &pbpeering.Peering{ var copyP pbpeering.Peering
ID: p.ID, proto.Merge(&copyP, p)
Name: p.Name,
Partition: p.Partition, // add new state, imported & exported services counts
DeletedAt: p.DeletedAt, copyP.State = state
Meta: p.Meta, copyP.ImportedServiceCount = isc
PeerID: p.PeerID, copyP.ExportedServiceCount = esc
PeerCAPems: p.PeerCAPems,
PeerServerAddresses: p.PeerServerAddresses, return &copyP
PeerServerName: p.PeerServerName,
CreateIndex: p.CreateIndex,
ModifyIndex: p.ModifyIndex,
ImportedServiceCount: isc,
ExportedServiceCount: esc,
State: state,
}
} }

Loading…
Cancel
Save