v2tenancy: register tenancy controller deps (#19531)

This commit is contained in:
Semir Patel 2023-11-07 08:06:10 -06:00 committed by GitHub
parent 5352ff945c
commit 2da7dd077a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 6 deletions

View File

@ -937,7 +937,10 @@ func isV1CatalogRequest(rpcName string) bool {
func (s *Server) registerControllers(deps Deps, proxyUpdater ProxyUpdater) error {
// When not enabled, the v1 tenancy bridge is used by default.
if s.useV2Tenancy {
tenancy.RegisterControllers(s.controllerManager)
tenancy.RegisterControllers(
s.controllerManager,
tenancy.Dependencies{Registry: deps.Registry},
)
}
if s.useV2Resources {

View File

@ -11,7 +11,6 @@ import (
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/consul/internal/resource"
"github.com/hashicorp/consul/proto-public/pbresource"
)
@ -68,7 +67,7 @@ func (m *Manager) Run(ctx context.Context) {
for _, desc := range m.controllers {
logger := desc.logger
if logger == nil {
logger = m.logger.With("managed_type", resource.ToGVK(desc.managedType))
logger = m.logger.With("managed_type", desc.managedType.Kind)
}
runner := &controllerRunner{

View File

@ -231,6 +231,17 @@ func (client *Client) WaitForStatusCondition(t T, id *pbresource.ID, statusKey s
return res
}
func (client *Client) WaitForStatusConditionAnyGen(t T, id *pbresource.ID, statusKey string, condition *pbresource.Condition) *pbresource.Resource {
t.Helper()
var res *pbresource.Resource
client.retry(t, func(r *retry.R) {
res = client.RequireStatusCondition(r, id, statusKey, condition)
})
return res
}
func (client *Client) WaitForStatusConditions(t T, id *pbresource.ID, statusKey string, conditions ...*pbresource.Condition) *pbresource.Resource {
t.Helper()

View File

@ -23,10 +23,12 @@ func RegisterTypes(r resource.Registry) {
// RegisterControllers registers controllers for the tenancy types with
// the given controller manager.
func RegisterControllers(mgr *controller.Manager) {
controllers.Register(mgr)
func RegisterControllers(mgr *controller.Manager, deps Dependencies) {
controllers.Register(mgr, deps)
}
func NewV2TenancyBridge() *V2TenancyBridge {
return bridge.NewV2TenancyBridge()
}
type Dependencies = controllers.Dependencies

View File

@ -0,0 +1,12 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package controllers
import (
"github.com/hashicorp/consul/internal/resource"
)
type Dependencies struct {
Registry resource.Registry
}

View File

@ -9,6 +9,6 @@ import (
"github.com/hashicorp/consul/internal/controller"
)
func Register(mgr *controller.Manager) {
func Register(mgr *controller.Manager, deps Dependencies) {
//mgr.Register(namespace.NamespaceController())
}