copy peering with merge

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

@ -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(&copyP, p)
// add new state, imported & exported services counts
copyP.State = state
copyP.ImportedServiceCount = isc
copyP.ExportedServiceCount = esc
return &copyP
}

Loading…
Cancel
Save