From 0961e241741ab980bb0e0dc8fa42e8f70bc6ae14 Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Fri, 6 Apr 2018 11:20:24 +0100 Subject: [PATCH] Remove namespace from more places --- cmd/controller/app/controller.go | 19 +------------------ pkg/controller/certificates/controller.go | 6 +----- pkg/controller/context.go | 3 --- pkg/issuer/context.go | 3 --- 4 files changed, 2 insertions(+), 29 deletions(-) diff --git a/cmd/controller/app/controller.go b/cmd/controller/app/controller.go index 9790d41ab..d8ac30a99 100644 --- a/cmd/controller/app/controller.go +++ b/cmd/controller/app/controller.go @@ -22,7 +22,6 @@ import ( intscheme "github.com/jetstack/cert-manager/pkg/client/clientset/versioned/scheme" informers "github.com/jetstack/cert-manager/pkg/client/informers/externalversions" "github.com/jetstack/cert-manager/pkg/controller" - "github.com/jetstack/cert-manager/pkg/controller/clusterissuers" "github.com/jetstack/cert-manager/pkg/issuer" "github.com/jetstack/cert-manager/pkg/util/kube" kubeinformers "k8s.io/client-go/informers" @@ -43,15 +42,7 @@ func Run(opts *options.ControllerOptions, stopCh <-chan struct{}) { run := func(_ <-chan struct{}) { var wg sync.WaitGroup - var controllers = make(map[string]controller.Interface) for n, fn := range controller.Known() { - if ctx.Namespace != "" && n == clusterissuers.ControllerName { - glog.Infof("Skipping ClusterIssuer controller as cert-manager is scoped to a single namespace") - continue - } - controllers[n] = fn(ctx) - } - for n, fn := range controllers { wg.Add(1) go func(n string, fn controller.Interface) { defer wg.Done() @@ -62,7 +53,7 @@ func Run(opts *options.ControllerOptions, stopCh <-chan struct{}) { if err != nil { glog.Fatalf("error running %s controller: %s", n, err.Error()) } - }(n, fn) + }(n, fn(ctx)) } glog.V(4).Infof("Starting shared informer factory") ctx.SharedInformerFactory.Start(stopCh) @@ -118,12 +109,6 @@ func buildControllerContext(opts *options.ControllerOptions) (*controller.Contex eventBroadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: cl.CoreV1().Events("")}) recorder := eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: controllerAgentName}) - // We only create SharedInformerFactories for the --namespace specified to - // watch. If this namespace is blank (i.e. the default, watch all - // namespaces) then the factories will watch all namespaces. - // If it is specified, all operations relating to ClusterIssuer resources - // should be disabled and thus we don't need to also create factories for - // the --cluster-resource-namespace. sharedInformerFactory := informers.NewSharedInformerFactory(intcl, time.Second*30) kubeSharedInformerFactory := kubeinformers.NewSharedInformerFactory(cl, time.Second*30) return &controller.Context{ @@ -138,13 +123,11 @@ func buildControllerContext(opts *options.ControllerOptions) (*controller.Contex Recorder: recorder, KubeSharedInformerFactory: kubeSharedInformerFactory, SharedInformerFactory: sharedInformerFactory, - Namespace: defaultNamespace, ClusterResourceNamespace: opts.ClusterResourceNamespace, ACMEHTTP01SolverImage: opts.ACMEHTTP01SolverImage, ClusterIssuerAmbientCredentials: opts.ClusterIssuerAmbientCredentials, IssuerAmbientCredentials: opts.IssuerAmbientCredentials, }), - Namespace: defaultNamespace, ClusterResourceNamespace: opts.ClusterResourceNamespace, }, kubeCfg, nil } diff --git a/pkg/controller/certificates/controller.go b/pkg/controller/certificates/controller.go index c0d9a4010..f27018237 100644 --- a/pkg/controller/certificates/controller.go +++ b/pkg/controller/certificates/controller.go @@ -233,14 +233,10 @@ const ( func init() { controllerpkg.Register(ControllerName, func(ctx *controllerpkg.Context) controllerpkg.Interface { - var clusterIssuerInformer cminformers.ClusterIssuerInformer - if ctx.Namespace == "" { - clusterIssuerInformer = ctx.SharedInformerFactory.Certmanager().V1alpha1().ClusterIssuers() - } return New( ctx.SharedInformerFactory.Certmanager().V1alpha1().Certificates(), ctx.SharedInformerFactory.Certmanager().V1alpha1().Issuers(), - clusterIssuerInformer, + ctx.SharedInformerFactory.Certmanager().V1alpha1().ClusterIssuers(), ctx.KubeSharedInformerFactory.Core().V1().Secrets(), ctx.KubeSharedInformerFactory.Extensions().V1beta1().Ingresses(), ctx.Client, diff --git a/pkg/controller/context.go b/pkg/controller/context.go index 9052b2d7e..e6113abb5 100644 --- a/pkg/controller/context.go +++ b/pkg/controller/context.go @@ -32,9 +32,6 @@ type Context struct { // instances IssuerFactory issuer.Factory - // Namespace is a namespace to operate within. This should be used when - // constructing SharedIndexInformers for the informer factory. - Namespace string // ClusterResourceNamespace is the namespace to store resources created by // non-namespaced resources (e.g. ClusterIssuer) in. ClusterResourceNamespace string diff --git a/pkg/issuer/context.go b/pkg/issuer/context.go index 3b56d8715..df632bcde 100644 --- a/pkg/issuer/context.go +++ b/pkg/issuer/context.go @@ -28,9 +28,6 @@ type Context struct { // instances SharedInformerFactory informers.SharedInformerFactory - // Namespace is a namespace to operate within. This should be used when - // constructing SharedIndexInformers for the informer factory. - Namespace string // ClusterResourceNamespace is the namespace to store resources created by // non-namespaced resources (e.g. ClusterIssuer) in. ClusterResourceNamespace string