diff --git a/internal/multicluster/exports.go b/internal/multicluster/exports.go index 624b839519..a4fc9a6e5d 100644 --- a/internal/multicluster/exports.go +++ b/internal/multicluster/exports.go @@ -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 diff --git a/internal/multicluster/internal/controllers/exportedservices/controller_test.go b/internal/multicluster/internal/controllers/exportedservices/controller_test.go index 7386c3ef1c..34a3a153e6 100644 --- a/internal/multicluster/internal/controllers/exportedservices/controller_test.go +++ b/internal/multicluster/internal/controllers/exportedservices/controller_test.go @@ -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"), }, }, }, diff --git a/internal/multicluster/internal/types/types.go b/internal/multicluster/internal/types/types.go index 9ee6691e19..1bc7279ce3 100644 --- a/internal/multicluster/internal/types/types.go +++ b/internal/multicluster/internal/types/types.go @@ -18,4 +18,6 @@ func Register(r resource.Registry) { RegisterNamespaceExportedServices(r) RegisterPartitionExportedServices(r) RegisterComputedExportedServices(r) + + RegisterEnterpriseTypes(r) } diff --git a/internal/multicluster/internal/types/types_ce.go b/internal/multicluster/internal/types/types_ce.go index 8c67cc8c30..22110e39ec 100644 --- a/internal/multicluster/internal/types/types_ce.go +++ b/internal/multicluster/internal/types/types_ce.go @@ -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 }