Skip to content

Commit

Permalink
Merge pull request #514 from FabianKramm/main
Browse files Browse the repository at this point in the history
refactor: reuse mapper provider for other managers
  • Loading branch information
FabianKramm authored Jun 2, 2022
2 parents 1791e26 + 5e06798 commit d9543e3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/controllers/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"github.com/loft-sh/vcluster/pkg/controllers/servicesync"
"github.com/loft-sh/vcluster/pkg/util/blockingcacheclient"
"github.com/loft-sh/vcluster/pkg/util/pluginhookclient"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
"strings"

Expand Down Expand Up @@ -188,7 +190,10 @@ func registerInitManifestsController(ctx *context.ControllerContext) error {
if ctx.Options.TargetNamespace != ctx.CurrentNamespace {
var err error
currentNamespaceManager, err = ctrl.NewManager(ctx.LocalManager.GetConfig(), ctrl.Options{
Scheme: ctx.LocalManager.GetScheme(),
Scheme: ctx.LocalManager.GetScheme(),
MapperProvider: func(c *rest.Config) (meta.RESTMapper, error) {
return ctx.LocalManager.GetRESTMapper(), nil
},
MetricsBindAddress: "0",
LeaderElection: false,
Namespace: ctx.CurrentNamespace,
Expand Down Expand Up @@ -234,7 +239,10 @@ func registerServiceSyncControllers(ctx *context.ControllerContext) error {
// sync we are syncing from arbitrary physical namespaces we need to create a new
// manager that listens on global services
globalLocalManager, err := ctrl.NewManager(ctx.LocalManager.GetConfig(), ctrl.Options{
Scheme: ctx.LocalManager.GetScheme(),
Scheme: ctx.LocalManager.GetScheme(),
MapperProvider: func(c *rest.Config) (meta.RESTMapper, error) {
return ctx.LocalManager.GetRESTMapper(), nil
},
MetricsBindAddress: "0",
LeaderElection: false,
NewClient: blockingcacheclient.NewCacheClient,
Expand Down

0 comments on commit d9543e3

Please sign in to comment.