From c4ce1be20506fb2fd9b4411bc003a4ade4bdd81e Mon Sep 17 00:00:00 2001 From: acpana <8968914+acpana@users.noreply.github.com> Date: Mon, 18 Jul 2022 13:22:16 -0700 Subject: [PATCH] copy peering with merge Signed-off-by: acpana <8968914+acpana@users.noreply.github.com> --- agent/rpc/peering/service.go | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/agent/rpc/peering/service.go b/agent/rpc/peering/service.go index 8512de1667..5001277248 100644 --- a/agent/rpc/peering/service.go +++ b/agent/rpc/peering/service.go @@ -13,6 +13,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" grpcstatus "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" "github.com/hashicorp/consul/acl" "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 { - return &pbpeering.Peering{ - ID: p.ID, - Name: p.Name, - Partition: p.Partition, - DeletedAt: p.DeletedAt, - Meta: p.Meta, - PeerID: p.PeerID, - PeerCAPems: p.PeerCAPems, - PeerServerAddresses: p.PeerServerAddresses, - PeerServerName: p.PeerServerName, - CreateIndex: p.CreateIndex, - ModifyIndex: p.ModifyIndex, - - ImportedServiceCount: isc, - ExportedServiceCount: esc, - - State: state, - } + var copyP pbpeering.Peering + proto.Merge(©P, p) + + // add new state, imported & exported services counts + copyP.State = state + copyP.ImportedServiceCount = isc + copyP.ExportedServiceCount = esc + + return ©P }