Move enterprise multicluster types to Register function (#19913)

* Move enterprise types to Register function

* Fix function name

* Address comments
This commit is contained in:
Ganesh S 2023-12-12 17:05:10 +05:30 committed by GitHub
parent 173fe11c2b
commit 90010587f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 92 deletions

View File

@ -21,7 +21,6 @@ var (
// to the given type registry
func RegisterTypes(r resource.Registry) {
types.Register(r)
types.RegisterEnterprise(r)
}
// RegisterControllers registers controllers for the multicluster types with

View File

@ -72,22 +72,14 @@ func (suite *controllerSuite) TestReconcile_DeleteOldCES_NoExportedServices() {
Name: "svc0",
},
Consumers: []*pbmulticluster.ComputedExportedServicesConsumer{
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Peer{
Peer: "test-peer",
},
},
suite.constructConsumer("test-peer", "peer"),
},
},
},
}
if suite.isEnterprise {
oldCESData.Consumers[0].Consumers = append(oldCESData.Consumers[0].Consumers, &pbmulticluster.ComputedExportedServicesConsumer{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Partition{
Partition: "part-n",
},
})
oldCESData.Consumers[0].Consumers = append(oldCESData.Consumers[0].Consumers, suite.constructConsumer("peer-n", "partition"))
}
oldCES := rtest.Resource(pbmulticluster.ComputedExportedServicesType, "global").
@ -118,22 +110,14 @@ func (suite *controllerSuite) TestReconcile_DeleteOldCES_NoMatchingServices() {
Name: "svc0",
},
Consumers: []*pbmulticluster.ComputedExportedServicesConsumer{
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Peer{
Peer: "test-peer",
},
},
suite.constructConsumer("test-peer", "peer"),
},
},
},
}
if suite.isEnterprise {
oldCESData.Consumers[0].Consumers = append(oldCESData.Consumers[0].Consumers, &pbmulticluster.ComputedExportedServicesConsumer{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Partition{
Partition: "part-n",
},
})
oldCESData.Consumers[0].Consumers = append(oldCESData.Consumers[0].Consumers, suite.constructConsumer("part-n", "partition"))
}
oldCES := rtest.Resource(pbmulticluster.ComputedExportedServicesType, "global").
@ -189,22 +173,14 @@ func (suite *controllerSuite) TestReconcile_SkipWritingNewCES() {
Name: "svc-0",
},
Consumers: []*pbmulticluster.ComputedExportedServicesConsumer{
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Peer{
Peer: "peer-1",
},
},
suite.constructConsumer("peer-1", "peer"),
},
},
},
}
if suite.isEnterprise {
oldCESData.Consumers[0].Consumers = append(oldCESData.Consumers[0].Consumers, &pbmulticluster.ComputedExportedServicesConsumer{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Partition{
Partition: "part-n",
},
})
oldCESData.Consumers[0].Consumers = append(oldCESData.Consumers[0].Consumers, suite.constructConsumer("part-n", "partition"))
}
oldCES := rtest.Resource(pbmulticluster.ComputedExportedServicesType, "global").
@ -312,26 +288,10 @@ func (suite *controllerSuite) TestReconcile_ComputeCES() {
Name: "svc-0",
},
Consumers: []*pbmulticluster.ComputedExportedServicesConsumer{
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Peer{
Peer: "peer-1",
},
},
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Peer{
Peer: "peer-2",
},
},
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Partition{
Partition: "part-1",
},
},
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Partition{
Partition: "part-n",
},
},
suite.constructConsumer("peer-1", "peer"),
suite.constructConsumer("peer-2", "peer"),
suite.constructConsumer("part-1", "partition"),
suite.constructConsumer("part-n", "partition"),
},
},
{
@ -341,21 +301,9 @@ func (suite *controllerSuite) TestReconcile_ComputeCES() {
Name: "svc-1",
},
Consumers: []*pbmulticluster.ComputedExportedServicesConsumer{
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Peer{
Peer: "peer-2",
},
},
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Partition{
Partition: "part-1",
},
},
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Partition{
Partition: "part-n",
},
},
suite.constructConsumer("peer-2", "peer"),
suite.constructConsumer("part-1", "partition"),
suite.constructConsumer("part-n", "partition"),
},
},
{
@ -365,21 +313,9 @@ func (suite *controllerSuite) TestReconcile_ComputeCES() {
Name: "svc-2",
},
Consumers: []*pbmulticluster.ComputedExportedServicesConsumer{
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Peer{
Peer: "peer-2",
},
},
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Partition{
Partition: "part-1",
},
},
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Partition{
Partition: "part-n",
},
},
suite.constructConsumer("peer-2", "peer"),
suite.constructConsumer("part-1", "partition"),
suite.constructConsumer("part-n", "partition"),
},
},
},
@ -394,16 +330,8 @@ func (suite *controllerSuite) TestReconcile_ComputeCES() {
Name: "svc-0",
},
Consumers: []*pbmulticluster.ComputedExportedServicesConsumer{
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Peer{
Peer: "peer-1",
},
},
{
ConsumerTenancy: &pbmulticluster.ComputedExportedServicesConsumer_Peer{
Peer: "peer-2",
},
},
suite.constructConsumer("peer-1", "peer"),
suite.constructConsumer("peer-2", "peer"),
},
},
},

View File

@ -18,4 +18,6 @@ func Register(r resource.Registry) {
RegisterNamespaceExportedServices(r)
RegisterPartitionExportedServices(r)
RegisterComputedExportedServices(r)
RegisterEnterpriseTypes(r)
}

View File

@ -7,5 +7,6 @@ package types
import "github.com/hashicorp/consul/internal/resource"
func RegisterEnterprise(r resource.Registry) {
func RegisterEnterpriseTypes(r resource.Registry) {
// no-op in CE
}