Rename `PeerName` to `Peer` on prepared queries and exported services (#14854)

This commit is contained in:
Eric Haberkorn 2022-10-04 14:46:15 -04:00 committed by GitHub
parent f5c8fe75e3
commit 2178e38204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 141 additions and 138 deletions

3
.changelog/14854.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:breaking-change
peering: Rename `PeerName` to `Peer` on prepared queries and exported services.
```

View File

@ -3334,19 +3334,19 @@ func TestInternal_ExportedPeeredServices_ACLEnforcement(t *testing.T) {
{
Name: "web",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-1"},
{Peer: "peer-1"},
},
},
{
Name: "db",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-2"},
{Peer: "peer-2"},
},
},
{
Name: "api",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-1"},
{Peer: "peer-1"},
},
},
},
@ -3405,7 +3405,7 @@ func TestInternal_ExportedPeeredServices_ACLEnforcement(t *testing.T) {
`
service "web" { policy = "read" }
service "api" { policy = "read" }
service "db" { policy = "deny" }
service "db" { policy = "deny" }
`),
expect: map[string]structs.ServiceList{
"peer-1": {
@ -3514,19 +3514,19 @@ func TestInternal_ExportedServicesForPeer_ACLEnforcement(t *testing.T) {
{
Name: "web",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-1"},
{Peer: "peer-1"},
},
},
{
Name: "db",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-2"},
{Peer: "peer-2"},
},
},
{
Name: "api",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-1"},
{Peer: "peer-1"},
},
},
},

View File

@ -257,7 +257,7 @@ func TestLeader_PeeringSync_Lifecycle_UnexportWhileDown(t *testing.T) {
Services: []structs.ExportedService{
{
Name: "foo",
Consumers: []structs.ServiceConsumer{{PeerName: "my-peer-dialer"}},
Consumers: []structs.ServiceConsumer{{Peer: "my-peer-dialer"}},
},
},
},
@ -1014,7 +1014,7 @@ func TestLeader_Peering_ImportedExportedServicesCount(t *testing.T) {
Name: structs.WildcardSpecifier,
Consumers: []structs.ServiceConsumer{
{
PeerName: "my-peer-s2",
Peer: "my-peer-s2",
},
},
},
@ -1042,7 +1042,7 @@ func TestLeader_Peering_ImportedExportedServicesCount(t *testing.T) {
Name: "a-service",
Consumers: []structs.ServiceConsumer{
{
PeerName: "my-peer-s2",
Peer: "my-peer-s2",
},
},
},
@ -1050,7 +1050,7 @@ func TestLeader_Peering_ImportedExportedServicesCount(t *testing.T) {
Name: "b-service",
Consumers: []structs.ServiceConsumer{
{
PeerName: "my-peer-s2",
Peer: "my-peer-s2",
},
},
},
@ -1069,7 +1069,7 @@ func TestLeader_Peering_ImportedExportedServicesCount(t *testing.T) {
Name: "a-service",
Consumers: []structs.ServiceConsumer{
{
PeerName: "my-peer-s2",
Peer: "my-peer-s2",
},
},
},
@ -1088,7 +1088,7 @@ func TestLeader_Peering_ImportedExportedServicesCount(t *testing.T) {
Name: "a-service",
Consumers: []structs.ServiceConsumer{
{
PeerName: "my-peer-s2",
Peer: "my-peer-s2",
},
},
},
@ -1096,7 +1096,7 @@ func TestLeader_Peering_ImportedExportedServicesCount(t *testing.T) {
Name: "c-service",
Consumers: []structs.ServiceConsumer{
{
PeerName: "my-peer-s2",
Peer: "my-peer-s2",
},
},
},

View File

@ -42,7 +42,7 @@ func TestWalk_ServiceQuery(t *testing.T) {
".Tags[0]:tag1",
".Tags[1]:tag2",
".Tags[2]:tag3",
".PeerName:",
".Peer:",
}
expected = append(expected, entMetaWalkFields...)
sort.Strings(expected)

View File

@ -540,7 +540,7 @@ func (p *PreparedQuery) execute(query *structs.PreparedQuery,
f = state.CheckConnectServiceNodes
}
_, nodes, err := f(nil, query.Service.Service, &query.Service.EnterpriseMeta, query.Service.PeerName)
_, nodes, err := f(nil, query.Service.Service, &query.Service.EnterpriseMeta, query.Service.Peer)
if err != nil {
return err
}
@ -571,7 +571,7 @@ func (p *PreparedQuery) execute(query *structs.PreparedQuery,
reply.DNS = query.DNS
// Stamp the result with its this datacenter or peer.
if peerName := query.Service.PeerName; peerName != "" {
if peerName := query.Service.Peer; peerName != "" {
reply.PeerName = peerName
reply.Datacenter = ""
} else {
@ -756,7 +756,7 @@ func queryFailover(q queryServer, query *structs.PreparedQuery,
}
}
if target.PeerName != "" {
if target.Peer != "" {
targets = append(targets, target)
}
}
@ -777,9 +777,9 @@ func queryFailover(q queryServer, query *structs.PreparedQuery,
// Reset PeerName because it may have been set by a previous failover
// target.
query.Service.PeerName = target.PeerName
query.Service.Peer = target.Peer
dc := target.Datacenter
if target.PeerName != "" {
if target.Peer != "" {
dc = q.GetLocalDC()
}
@ -798,7 +798,7 @@ func queryFailover(q queryServer, query *structs.PreparedQuery,
if err = q.ExecuteRemote(remote, reply); err != nil {
q.GetLogger().Warn("Failed querying for service in datacenter",
"service", query.Service.Service,
"peerName", query.Service.PeerName,
"peerName", query.Service.Peer,
"datacenter", dc,
"error", err,
)

View File

@ -88,7 +88,7 @@ func TestPreparedQuery_Apply(t *testing.T) {
// Fix that and ensure Targets and NearestN cannot be set at the same time.
query.Query.Service.Failover.NearestN = 1
query.Query.Service.Failover.Targets = []structs.QueryFailoverTarget{{PeerName: "peer"}}
query.Query.Service.Failover.Targets = []structs.QueryFailoverTarget{{Peer: "peer"}}
err = msgpackrpc.CallWithCodec(codec, "PreparedQuery.Apply", &query, &reply)
if err == nil || !strings.Contains(err.Error(), "Targets cannot be populated with") {
t.Fatalf("bad: %v", err)
@ -97,7 +97,7 @@ func TestPreparedQuery_Apply(t *testing.T) {
// Fix that and ensure Targets and Datacenters cannot be set at the same time.
query.Query.Service.Failover.NearestN = 0
query.Query.Service.Failover.Datacenters = []string{"dc2"}
query.Query.Service.Failover.Targets = []structs.QueryFailoverTarget{{PeerName: "peer"}}
query.Query.Service.Failover.Targets = []structs.QueryFailoverTarget{{Peer: "peer"}}
err = msgpackrpc.CallWithCodec(codec, "PreparedQuery.Apply", &query, &reply)
if err == nil || !strings.Contains(err.Error(), "Targets cannot be populated with") {
t.Fatalf("bad: %v", err)
@ -1552,7 +1552,7 @@ func TestPreparedQuery_Execute(t *testing.T) {
Services: []structs.ExportedService{
{
Name: "foo",
Consumers: []structs.ServiceConsumer{{PeerName: dialingPeerName}},
Consumers: []structs.ServiceConsumer{{Peer: dialingPeerName}},
},
},
},
@ -2429,7 +2429,7 @@ func TestPreparedQuery_Execute(t *testing.T) {
query.Query.Service.Failover = structs.QueryFailoverOptions{
Targets: []structs.QueryFailoverTarget{
{Datacenter: "dc2"},
{PeerName: acceptingPeerName},
{Peer: acceptingPeerName},
},
}
require.NoError(t, msgpackrpc.CallWithCodec(codec1, "PreparedQuery.Apply", &query, &query.Query.ID))
@ -2950,7 +2950,7 @@ func (m *mockQueryServer) GetOtherDatacentersByDistance() ([]string, error) {
}
func (m *mockQueryServer) ExecuteRemote(args *structs.PreparedQueryExecuteRemoteRequest, reply *structs.PreparedQueryExecuteResponse) error {
peerName := args.Query.Service.PeerName
peerName := args.Query.Service.Peer
dc := args.Datacenter
if peerName != "" {
m.QueryLog = append(m.QueryLog, fmt.Sprintf("peer:%s", peerName))
@ -3302,15 +3302,15 @@ func TestPreparedQuery_queryFailover(t *testing.T) {
// Failover returns data from the first cluster peer with data.
query.Service.Failover.Datacenters = nil
query.Service.Failover.Targets = []structs.QueryFailoverTarget{
{PeerName: "cluster-01"},
{Peer: "cluster-01"},
{Datacenter: "dc44"},
{PeerName: "cluster-02"},
{Peer: "cluster-02"},
}
{
mock := &mockQueryServer{
Datacenters: []string{"dc44"},
QueryFn: func(args *structs.PreparedQueryExecuteRemoteRequest, reply *structs.PreparedQueryExecuteResponse) error {
if args.Query.Service.PeerName == "cluster-02" {
if args.Query.Service.Peer == "cluster-02" {
reply.Nodes = nodes()
}
return nil

View File

@ -63,7 +63,7 @@ func TestStore_peersForService(t *testing.T) {
Name: "not-" + queryName,
Consumers: []structs.ServiceConsumer{
{
PeerName: "zip",
Peer: "zip",
},
},
},
@ -80,7 +80,7 @@ func TestStore_peersForService(t *testing.T) {
Name: "not-" + queryName,
Consumers: []structs.ServiceConsumer{
{
PeerName: "zip",
Peer: "zip",
},
},
},
@ -88,10 +88,10 @@ func TestStore_peersForService(t *testing.T) {
Name: structs.WildcardSpecifier,
Consumers: []structs.ServiceConsumer{
{
PeerName: "bar",
Peer: "bar",
},
{
PeerName: "baz",
Peer: "baz",
},
},
},
@ -108,7 +108,7 @@ func TestStore_peersForService(t *testing.T) {
Name: queryName,
Consumers: []structs.ServiceConsumer{
{
PeerName: "baz",
Peer: "baz",
},
},
},
@ -116,7 +116,7 @@ func TestStore_peersForService(t *testing.T) {
Name: structs.WildcardSpecifier,
Consumers: []structs.ServiceConsumer{
{
PeerName: "zip",
Peer: "zip",
},
},
},

View File

@ -1569,7 +1569,7 @@ func TestStore_ConfigEntry_GraphValidation(t *testing.T) {
Name: "default",
Services: []structs.ExportedService{{
Name: "main",
Consumers: []structs.ServiceConsumer{{PeerName: "my-peer"}},
Consumers: []structs.ServiceConsumer{{Peer: "my-peer"}},
}},
},
expectErr: `contains cross-datacenter resolver redirect`,
@ -1588,7 +1588,7 @@ func TestStore_ConfigEntry_GraphValidation(t *testing.T) {
Name: "default",
Services: []structs.ExportedService{{
Name: "*",
Consumers: []structs.ServiceConsumer{{PeerName: "my-peer"}},
Consumers: []structs.ServiceConsumer{{Peer: "my-peer"}},
}},
},
expectErr: `contains cross-datacenter resolver redirect`,
@ -1609,7 +1609,7 @@ func TestStore_ConfigEntry_GraphValidation(t *testing.T) {
Name: "default",
Services: []structs.ExportedService{{
Name: "main",
Consumers: []structs.ServiceConsumer{{PeerName: "my-peer"}},
Consumers: []structs.ServiceConsumer{{Peer: "my-peer"}},
}},
},
expectErr: `contains cross-datacenter failover`,
@ -1630,7 +1630,7 @@ func TestStore_ConfigEntry_GraphValidation(t *testing.T) {
Name: "default",
Services: []structs.ExportedService{{
Name: "*",
Consumers: []structs.ServiceConsumer{{PeerName: "my-peer"}},
Consumers: []structs.ServiceConsumer{{Peer: "my-peer"}},
}},
},
expectErr: `contains cross-datacenter failover`,
@ -1641,7 +1641,7 @@ func TestStore_ConfigEntry_GraphValidation(t *testing.T) {
Name: "default",
Services: []structs.ExportedService{{
Name: "main",
Consumers: []structs.ServiceConsumer{{PeerName: "my-peer"}},
Consumers: []structs.ServiceConsumer{{Peer: "my-peer"}},
}},
},
},

View File

@ -794,7 +794,7 @@ func exportedServicesForPeerTxn(
// Service was covered by a wildcard that was already accounted for
continue
}
if consumer.PeerName != peering.Name {
if consumer.Peer != peering.Name {
continue
}
sawPeer = true
@ -940,7 +940,7 @@ func listServicesExportedToAnyPeerByConfigEntry(
sawPeer := false
for _, consumer := range svc.Consumers {
if consumer.PeerName == "" {
if consumer.Peer == "" {
continue
}
sawPeer = true
@ -1312,8 +1312,8 @@ func peersForServiceTxn(
}
for _, c := range entry.Services[targetIdx].Consumers {
if c.PeerName != "" {
results = append(results, c.PeerName)
if c.Peer != "" {
results = append(results, c.Peer)
}
}
return idx, results, nil

View File

@ -1686,19 +1686,19 @@ func TestStateStore_ExportedServicesForPeer(t *testing.T) {
{
Name: "mysql",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-peering"},
{Peer: "my-peering"},
},
},
{
Name: "redis",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-peering"},
{Peer: "my-peering"},
},
},
{
Name: "mongo",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-other-peering"},
{Peer: "my-other-peering"},
},
},
},
@ -1758,7 +1758,7 @@ func TestStateStore_ExportedServicesForPeer(t *testing.T) {
{
Name: "*",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-peering"},
{Peer: "my-peering"},
},
},
},
@ -2046,10 +2046,10 @@ func TestStateStore_PeeringsForService(t *testing.T) {
Name: "foo",
Consumers: []structs.ServiceConsumer{
{
PeerName: "peer1",
Peer: "peer1",
},
{
PeerName: "peer2",
Peer: "peer2",
},
},
},
@ -2090,7 +2090,7 @@ func TestStateStore_PeeringsForService(t *testing.T) {
Name: "foo",
Consumers: []structs.ServiceConsumer{
{
PeerName: "peer1",
Peer: "peer1",
},
},
},
@ -2098,7 +2098,7 @@ func TestStateStore_PeeringsForService(t *testing.T) {
Name: "bar",
Consumers: []structs.ServiceConsumer{
{
PeerName: "peer2",
Peer: "peer2",
},
},
},
@ -2148,10 +2148,10 @@ func TestStateStore_PeeringsForService(t *testing.T) {
Name: "*",
Consumers: []structs.ServiceConsumer{
{
PeerName: "peer1",
Peer: "peer1",
},
{
PeerName: "peer2",
Peer: "peer2",
},
},
},
@ -2159,7 +2159,7 @@ func TestStateStore_PeeringsForService(t *testing.T) {
Name: "bar",
Consumers: []structs.ServiceConsumer{
{
PeerName: "peer3",
Peer: "peer3",
},
},
},
@ -2261,7 +2261,7 @@ func TestStore_TrustBundleListByService(t *testing.T) {
Name: "foo",
Consumers: []structs.ServiceConsumer{
{
PeerName: "peer1",
Peer: "peer1",
},
},
},
@ -2318,7 +2318,7 @@ func TestStore_TrustBundleListByService(t *testing.T) {
Name: "foo",
Consumers: []structs.ServiceConsumer{
{
PeerName: "peer1",
Peer: "peer1",
},
},
},
@ -2371,10 +2371,10 @@ func TestStore_TrustBundleListByService(t *testing.T) {
Name: "foo",
Consumers: []structs.ServiceConsumer{
{
PeerName: "peer1",
Peer: "peer1",
},
{
PeerName: "peer2",
Peer: "peer2",
},
},
},

View File

@ -864,14 +864,14 @@ func TestStreamResources_Server_ServiceUpdates(t *testing.T) {
{
Name: "mysql",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-peering"},
{Peer: "my-peering"},
},
},
{
// Mongo does not get pushed because it does not have instances registered.
Name: "mongo",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-peering"},
{Peer: "my-peering"},
},
},
},
@ -1035,7 +1035,7 @@ func TestStreamResources_Server_ServiceUpdates(t *testing.T) {
Name: "mongo",
Consumers: []structs.ServiceConsumer{
{
PeerName: "my-peering",
Peer: "my-peering",
},
},
},

View File

@ -80,13 +80,13 @@ func TestSubscriptionManager_RegisterDeregister(t *testing.T) {
{
Name: "mysql",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-peering"},
{Peer: "my-peering"},
},
},
{
Name: "mongo",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-other-peering"},
{Peer: "my-other-peering"},
},
},
},
@ -429,7 +429,7 @@ func TestSubscriptionManager_RegisterDeregister(t *testing.T) {
{
Name: "mongo",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-other-peering"},
{Peer: "my-other-peering"},
},
},
},
@ -506,19 +506,19 @@ func TestSubscriptionManager_InitialSnapshot(t *testing.T) {
{
Name: "mysql",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-peering"},
{Peer: "my-peering"},
},
},
{
Name: "mongo",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-peering"},
{Peer: "my-peering"},
},
},
{
Name: "chain",
Consumers: []structs.ServiceConsumer{
{PeerName: "my-peering"},
{Peer: "my-peering"},
},
},
},

View File

@ -36,13 +36,13 @@ func TestServerExportedPeeredServices(t *testing.T) {
{
Name: "web",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-1"},
{Peer: "peer-1"},
},
},
{
Name: "db",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-2"},
{Peer: "peer-2"},
},
},
},
@ -78,20 +78,20 @@ func TestServerExportedPeeredServices(t *testing.T) {
{
Name: "web",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-1"},
{Peer: "peer-1"},
},
},
{
Name: "db",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-2"},
{Peer: "peer-2"},
},
},
{
Name: "api",
Consumers: []structs.ServiceConsumer{
{PeerName: "peer-1"},
{PeerName: "peer-3"},
{Peer: "peer-1"},
{Peer: "peer-3"},
},
},
},

View File

@ -144,7 +144,7 @@ func TestServerTrustBundleList(t *testing.T) {
{
Name: serviceName,
Consumers: []structs.ServiceConsumer{
{PeerName: them},
{Peer: them},
},
},
},
@ -249,7 +249,7 @@ func TestServerTrustBundleList_ACLEnforcement(t *testing.T) {
{
Name: serviceName,
Consumers: []structs.ServiceConsumer{
{PeerName: them},
{Peer: them},
},
},
},

View File

@ -1059,10 +1059,10 @@ func TestPeeringService_TrustBundleListByService(t *testing.T) {
Name: "api",
Consumers: []structs.ServiceConsumer{
{
PeerName: "foo",
Peer: "foo",
},
{
PeerName: "bar",
Peer: "bar",
},
},
},
@ -1070,7 +1070,7 @@ func TestPeeringService_TrustBundleListByService(t *testing.T) {
Name: "web",
Consumers: []structs.ServiceConsumer{
{
PeerName: "baz",
Peer: "baz",
},
},
},
@ -1264,7 +1264,7 @@ func TestPeeringService_TrustBundleListByService_ACLEnforcement(t *testing.T) {
Name: "api",
Consumers: []structs.ServiceConsumer{
{
PeerName: "foo",
Peer: "foo",
},
},
},

View File

@ -17,7 +17,7 @@ func TestExportedServicesConfigEntry_OSS(t *testing.T) {
Name: "web",
Consumers: []ServiceConsumer{
{
PeerName: "bar",
Peer: "bar",
},
},
},
@ -31,7 +31,7 @@ func TestExportedServicesConfigEntry_OSS(t *testing.T) {
Namespace: "",
Consumers: []ServiceConsumer{
{
PeerName: "bar",
Peer: "bar",
},
},
},

View File

@ -35,14 +35,14 @@ type ExportedService struct {
}
// ServiceConsumer represents a downstream consumer of the service to be exported.
// At most one of Partition or PeerName must be specified.
// At most one of Partition or Peer must be specified.
type ServiceConsumer struct {
// Partition is the admin partition to export the service to.
// Deprecated: PeerName should be used for both remote peers and local partitions.
// Deprecated: Peer should be used for both remote peers and local partitions.
Partition string `json:",omitempty"`
// PeerName is the name of the peer to export the service to.
PeerName string `json:",omitempty" alias:"peer_name"`
// Peer is the name of the peer to export the service to.
Peer string `json:",omitempty" alias:"peer_name"`
}
func (e *ExportedServicesConfigEntry) ToMap() map[string]map[string][]string {
@ -130,13 +130,13 @@ func (e *ExportedServicesConfigEntry) Validate() error {
return fmt.Errorf("Services[%d]: must have at least one consumer", i)
}
for j, consumer := range svc.Consumers {
if consumer.PeerName != "" && consumer.Partition != "" {
return fmt.Errorf("Services[%d].Consumers[%d]: must define at most one of PeerName or Partition", i, j)
if consumer.Peer != "" && consumer.Partition != "" {
return fmt.Errorf("Services[%d].Consumers[%d]: must define at most one of Peer or Partition", i, j)
}
if consumer.Partition == WildcardSpecifier {
return fmt.Errorf("Services[%d].Consumers[%d]: exporting to all partitions (wildcard) is not supported", i, j)
}
if consumer.PeerName == WildcardSpecifier {
if consumer.Peer == WildcardSpecifier {
return fmt.Errorf("Services[%d].Consumers[%d]: exporting to all peers (wildcard) is not supported", i, j)
}
}

View File

@ -60,10 +60,10 @@ func TestExportedServicesConfigEntry(t *testing.T) {
Name: "web",
Consumers: []ServiceConsumer{
{
PeerName: "foo",
Peer: "foo",
},
{
PeerName: "*",
Peer: "*",
},
},
},
@ -80,13 +80,13 @@ func TestExportedServicesConfigEntry(t *testing.T) {
Consumers: []ServiceConsumer{
{
Partition: "foo",
PeerName: "bar",
Peer: "bar",
},
},
},
},
},
validateErr: `Services[0].Consumers[0]: must define at most one of PeerName or Partition`,
validateErr: `Services[0].Consumers[0]: must define at most one of Peer or Partition`,
},
}

View File

@ -1951,7 +1951,7 @@ func TestDecodeConfigEntry(t *testing.T) {
Partition = "baz"
},
{
PeerName = "flarm"
Peer = "flarm"
}
]
},
@ -1984,7 +1984,7 @@ func TestDecodeConfigEntry(t *testing.T) {
Partition: "baz",
},
{
PeerName: "flarm",
Peer: "flarm",
},
},
},

View File

@ -42,8 +42,8 @@ func (f *QueryFailoverOptions) AsTargets() []QueryFailoverTarget {
}
type QueryFailoverTarget struct {
// PeerName specifies a peer to try during failover.
PeerName string
// Peer specifies a peer to try during failover.
Peer string
// Datacenter specifies a datacenter to try during failover.
Datacenter string
@ -105,9 +105,9 @@ type ServiceQuery struct {
// should be directly next to their services so this isn't an issue.
Connect bool
// If not empty, PeerName represents the peer that the service
// If not empty, Peer represents the peer that the service
// was imported from.
PeerName string
Peer string
// EnterpriseMeta is the embedded enterprise metadata
acl.EnterpriseMeta `hcl:",squash" mapstructure:",squash"`

View File

@ -779,7 +779,7 @@ func TestUIExportedServices(t *testing.T) {
Name: "api",
Consumers: []structs.ServiceConsumer{
{
PeerName: "peer1",
Peer: "peer1",
},
},
},

View File

@ -50,8 +50,8 @@ type ServiceConsumer struct {
// Deprecated: PeerName should be used for both remote peers and local partitions.
Partition string `json:",omitempty"`
// PeerName is the name of the peer to export the service to.
PeerName string `json:",omitempty" alias:"peer_name"`
// Peer is the name of the peer to export the service to.
Peer string `json:",omitempty" alias:"peer_name"`
}
func (e *ExportedServicesConfigEntry) GetKind() string { return ExportedServices }

View File

@ -51,7 +51,7 @@ func TestAPI_ConfigEntries_ExportedServices(t *testing.T) {
Namespace: defaultNamespace,
Consumers: []ServiceConsumer{
{
PeerName: "alpha",
Peer: "alpha",
},
},
},

View File

@ -21,8 +21,8 @@ type QueryFailoverOptions struct {
type QueryDatacenterOptions = QueryFailoverOptions
type QueryFailoverTarget struct {
// PeerName specifies a peer to try during failover.
PeerName string
// Peer specifies a peer to try during failover.
Peer string
// Datacenter specifies a datacenter to try during failover.
Datacenter string

View File

@ -715,7 +715,7 @@ func TestParseConfigEntry(t *testing.T) {
},
"destination": {
"addresses": [
"10.0.0.0",
"10.0.0.0",
"10.0.0.1"
],
"port": 443
@ -741,7 +741,7 @@ func TestParseConfigEntry(t *testing.T) {
},
"Destination": {
"Addresses": [
"10.0.0.0",
"10.0.0.0",
"10.0.0.1"
],
"Port": 443
@ -2911,7 +2911,7 @@ func TestParseConfigEntry(t *testing.T) {
Partition = "baz"
},
{
PeerName = "flarm"
Peer = "flarm"
}
]
},
@ -2982,7 +2982,7 @@ func TestParseConfigEntry(t *testing.T) {
"Partition": "baz"
},
{
"PeerName": "flarm"
"Peer": "flarm"
}
]
},
@ -3016,7 +3016,7 @@ func TestParseConfigEntry(t *testing.T) {
Partition: "baz",
},
{
PeerName: "flarm",
Peer: "flarm",
},
},
},

View File

@ -16,7 +16,7 @@ config_entries {
name = "s2"
consumers = [
{
peer_name = "alpha-to-primary"
peer = "alpha-to-primary"
}
]
}

View File

@ -29,7 +29,7 @@ config_entries {
name = "s2"
consumers = [
{
peer_name = "alpha-to-primary"
peer = "alpha-to-primary"
}
]
}

View File

@ -16,7 +16,7 @@ config_entries {
name = "s2"
consumers = [
{
peer_name = "alpha-to-primary"
peer = "alpha-to-primary"
}
]
}

View File

@ -23,7 +23,7 @@ config_entries {
name = "s2"
consumers = [
{
peer_name = "alpha-to-primary"
peer = "alpha-to-primary"
}
]
}

View File

@ -16,7 +16,7 @@ config_entries {
name = "s2"
consumers = [
{
peer_name = "alpha-to-primary"
peer = "alpha-to-primary"
}
]
}

View File

@ -207,7 +207,7 @@ The table below shows this endpoint's support for
service instances in the local datacenter.
This option cannot be used with `NearestN` or `Datacenters`.
- `PeerName` `(string: "")` - Specifies a [cluster peer](/docs/connect/cluster-peering) to use for
- `Peer` `(string: "")` - Specifies a [cluster peer](/docs/connect/cluster-peering) to use for
failover.
- `Datacenter` `(string: "")` - Specifies a WAN federated datacenter to forward the

View File

@ -46,7 +46,7 @@ Services = [
Name = "<name of service to export>"
Consumers = [
{
PeerName = "<name of the peered cluster that dials the exported service>"
Peer = "<name of the peered cluster that dials the exported service>"
}
]
}
@ -73,7 +73,7 @@ spec:
"Name": "<name of service to export>",
"Consumers": [
{
"PeerName": "<name of the peered cluster that dials the exported service>"
"Peer": "<name of the peered cluster that dials the exported service>"
}
]
}
@ -96,7 +96,7 @@ Services = [
Namespace = "<namespace in the partition containing the service to export>"
Consumers = [
{
PeerName = "<name of the peered cluster that dials the exported service>"
Peer = "<name of the peered cluster that dials the exported service>"
}
]
}
@ -126,7 +126,7 @@ spec:
"Namespace": "<namespace in the partition containing the service to export>"
"Consumers": [
{
"PeerName": "<name of the peered cluster that dials the exported service>"
"Peer": "<name of the peered cluster that dials the exported service>"
}
]
}
@ -215,8 +215,8 @@ The `Services` parameter contains a list of one or more parameters that specify
The `Consumers` parameter contains a list of one or more parameters that specify the destination cluster for
an exported service. Each item in the `Consumers` list must contain exactly one of the following parameters:
- `PeerName`: Specifies the name of the peered cluster to export the service to.
A asterisk wildcard (`*`) cannot be specified as the `PeerName`. Added in Consul 1.13.0.
- `Peer`: Specifies the name of the peered cluster to export the service to.
A asterisk wildcard (`*`) cannot be specified as the `Peer`. Added in Consul 1.13.0.
- `Partition`: <EnterpriseAlert inline /> Specifies an admin partition in the datacenter to export the service to.
A asterisk wildcard (`*`) cannot be specified as the `Partition`.
@ -242,7 +242,7 @@ Services = [
Name = "payments"
Consumers = [
{
PeerName = "web-shop"
Peer = "web-shop"
},
]
},
@ -250,7 +250,7 @@ Services = [
Name = "refunds"
Consumers = [
{
PeerName = "web-shop"
Peer = "web-shop"
}
]
}
@ -280,7 +280,7 @@ spec:
"Name": "payments",
"Consumers": [
{
"PeerName": "web-shop"
"Peer": "web-shop"
},
],
},
@ -288,7 +288,7 @@ spec:
"Name": "refunds",
"Consumers": [
{
"PeerName": "web-shop"
"Peer": "web-shop"
}
]
}
@ -315,7 +315,7 @@ Services = [
Namespace = "billing"
Consumers = [
{
PeerName = "web-shop"
Peer = "web-shop"
},
]
},
@ -324,7 +324,7 @@ Services = [
Namespace = "billing"
Consumers = [
{
PeerName = "web-shop"
Peer = "web-shop"
}
]
}
@ -358,7 +358,7 @@ spec:
"Namespace": "billing"
"Consumers": [
{
"PeerName": "web-shop"
"Peer": "web-shop"
},
],
},
@ -367,7 +367,7 @@ spec:
"Namespace": "billing",
"Consumers": [
{
"PeerName": "web-shop"
"Peer": "web-shop"
}
]
}
@ -475,10 +475,10 @@ Services = [
Name = "*"
Consumers = [
{
PeerName = "monitoring"
Peer = "monitoring"
},
{
PeerName = "platform"
Peer = "platform"
}
]
}
@ -507,10 +507,10 @@ spec:
"Namespace": "*"
"Consumers": [
{
"PeerName": "monitoring"
"Peer": "monitoring"
},
{
"PeerName": "platform"
"Peer": "platform"
}
]
}
@ -537,10 +537,10 @@ Services = [
Namespace = "*"
Consumers = [
{
PeerName = "monitoring"
Peer = "monitoring"
},
{
PeerName = "platform"
Peer = "platform"
}
]
}
@ -571,10 +571,10 @@ spec:
"Namespace": "*"
"Consumers": [
{
"PeerName": "monitoring"
"Peer": "monitoring"
},
{
"PeerName": "platform"
"Peer": "platform"
}
]
}