mirror of
https://github.com/status-im/consul.git
synced 2025-01-22 03:29:43 +00:00
resource: default peername to "local" for now (#18822)
This commit is contained in:
parent
e24b3d9b3f
commit
d3dad14030
@ -147,7 +147,7 @@ func validateId(id *pbresource.ID, errorPrefix string) error {
|
||||
id.Tenancy = &pbresource.Tenancy{
|
||||
Partition: "",
|
||||
Namespace: "",
|
||||
// TODO(spatel): Remove when peerTenancy introduced.
|
||||
// TODO(spatel): NET-5475 - Remove as part of peer_name moving to PeerTenancy
|
||||
PeerName: "local",
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ func (s *Server) validateWriteStatusRequest(req *pbresource.WriteStatusRequest)
|
||||
req.Id.Tenancy = &pbresource.Tenancy{
|
||||
Partition: "",
|
||||
Namespace: "",
|
||||
// TODO(spatel): Remove when peerTenancy introduced.
|
||||
// TODO(spatel): NET-5475 - Remove as part of peer_name moving to PeerTenancy
|
||||
PeerName: "local",
|
||||
}
|
||||
}
|
||||
|
@ -256,6 +256,14 @@ func TestWrite_Create_Success(t *testing.T) {
|
||||
},
|
||||
expectedTenancy: resource.DefaultNamespacedTenancy(),
|
||||
},
|
||||
// TODO(spatel): NET-5475 - Remove as part of peer_name moving to PeerTenancy
|
||||
"namespaced resource defaults peername to local when empty": {
|
||||
modFn: func(artist, _ *pbresource.Resource) *pbresource.Resource {
|
||||
artist.Id.Tenancy.PeerName = ""
|
||||
return artist
|
||||
},
|
||||
expectedTenancy: resource.DefaultNamespacedTenancy(),
|
||||
},
|
||||
"partitioned resource provides nonempty partition": {
|
||||
modFn: func(_, recordLabel *pbresource.Resource) *pbresource.Resource {
|
||||
return recordLabel
|
||||
@ -283,6 +291,14 @@ func TestWrite_Create_Success(t *testing.T) {
|
||||
},
|
||||
expectedTenancy: resource.DefaultPartitionedTenancy(),
|
||||
},
|
||||
// TODO(spatel): NET-5475 - Remove as part of peer_name moving to PeerTenancy
|
||||
"partitioned resource defaults peername to local when empty": {
|
||||
modFn: func(_, recordLabel *pbresource.Resource) *pbresource.Resource {
|
||||
recordLabel.Id.Tenancy.PeerName = ""
|
||||
return recordLabel
|
||||
},
|
||||
expectedTenancy: resource.DefaultPartitionedTenancy(),
|
||||
},
|
||||
// TODO(spatel): Add cluster scope tests when we have an actual cluster scoped resource (e.g. partition)
|
||||
}
|
||||
for desc, tc := range testCases {
|
||||
|
@ -52,12 +52,17 @@ func Normalize(tenancy *pbresource.Tenancy) {
|
||||
}
|
||||
tenancy.Partition = strings.ToLower(tenancy.Partition)
|
||||
tenancy.Namespace = strings.ToLower(tenancy.Namespace)
|
||||
|
||||
// TODO(spatel): NET-5475 - Remove as part of peer_name moving to PeerTenancy
|
||||
if tenancy.PeerName == "" {
|
||||
tenancy.PeerName = "local"
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultClusteredTenancy returns the default tenancy for a cluster scoped resource.
|
||||
func DefaultClusteredTenancy() *pbresource.Tenancy {
|
||||
return &pbresource.Tenancy{
|
||||
// TODO(spatel): Remove as part of "peer is not part of tenancy" ADR
|
||||
// TODO(spatel): NET-5475 - Remove as part of peer_name moving to PeerTenancy
|
||||
PeerName: "local",
|
||||
}
|
||||
}
|
||||
@ -66,7 +71,7 @@ func DefaultClusteredTenancy() *pbresource.Tenancy {
|
||||
func DefaultPartitionedTenancy() *pbresource.Tenancy {
|
||||
return &pbresource.Tenancy{
|
||||
Partition: DefaultPartitionName,
|
||||
// TODO(spatel): Remove as part of "peer is not part of tenancy" ADR
|
||||
// TODO(spatel): NET-5475 - Remove as part of peer_name moving to PeerTenancy
|
||||
PeerName: "local",
|
||||
}
|
||||
}
|
||||
@ -76,7 +81,7 @@ func DefaultNamespacedTenancy() *pbresource.Tenancy {
|
||||
return &pbresource.Tenancy{
|
||||
Partition: DefaultPartitionName,
|
||||
Namespace: DefaultNamespaceName,
|
||||
// TODO(spatel): Remove as part of "peer is not part of tenancy" ADR
|
||||
// TODO(spatel): NET-5475 - Remove as part of peer_name moving to PeerTenancy
|
||||
PeerName: "local",
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user