Skip to content

Commit

Permalink
Revert back to old structure
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Aug 16, 2021
1 parent a3581bc commit a8eb885
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
20 changes: 11 additions & 9 deletions pkg/controller/controller.go
Expand Up @@ -65,15 +65,6 @@ type Controller struct {
Recorder record.EventRecorder
// Audit Event Publisher
Auditor *auditlib.EventPublisher
// Only watch or reconcile objects in this namespace (usually for license reasons)
RestrictToNamespace string
// Secret
SecretInformer cache.SharedIndexInformer
SecretLister corelisters.SecretLister
// StatefulSet Watcher
StsQueue *queue.Worker
StsInformer cache.SharedIndexInformer
StsLister appslister.StatefulSetLister
}

type Config struct {
Expand All @@ -87,6 +78,17 @@ type Config struct {
// External tool to initialize the database
Initializers Initializers

// Secret
SecretInformer cache.SharedIndexInformer
SecretLister corelisters.SecretLister

// StatefulSet Watcher
StsQueue *queue.Worker
StsInformer cache.SharedIndexInformer
StsLister appslister.StatefulSetLister

// Only watch or reconcile objects in this namespace (usually for license reasons)
RestrictToNamespace string
ResyncPeriod time.Duration
ReadinessProbeInterval time.Duration
MaxNumRequeues int
Expand Down
11 changes: 7 additions & 4 deletions pkg/controller/initializer/stash/controller.go
Expand Up @@ -35,15 +35,18 @@ import (
type Controller struct {
*amc.Controller
*amc.StashInitializer
restrictToNamespace string
}

func NewController(
ctrl *amc.Controller,
initializer *amc.StashInitializer,
restrictToNamespace string,
) *Controller {
return &Controller{
Controller: ctrl,
StashInitializer: initializer,
Controller: ctrl,
StashInitializer: initializer,
restrictToNamespace: restrictToNamespace,
}
}

Expand Down Expand Up @@ -95,13 +98,13 @@ func (c *Controller) initWatcher(maxNumRequeues, numThreads int, selector metav1
c.RSInformer = c.restoreSessionInformer(tweakListOptions)
c.RSQueue = queue.New(v1beta1.ResourceKindRestoreSession, maxNumRequeues, numThreads, c.processRestoreSession)
c.RSLister = c.StashInformerFactory.Stash().V1beta1().RestoreSessions().Lister()
c.RSInformer.AddEventHandler(queue.NewFilteredHandler(queue.NewChangeHandler(c.RSQueue.GetQueue(), c.Controller.RestrictToNamespace), ls))
c.RSInformer.AddEventHandler(queue.NewFilteredHandler(queue.NewChangeHandler(c.RSQueue.GetQueue(), c.restrictToNamespace), ls))

// Initialize RestoreBatch Watcher
c.RBInformer = c.restoreBatchInformer(tweakListOptions)
c.RBQueue = queue.New(v1beta1.ResourceKindRestoreBatch, maxNumRequeues, numThreads, c.processRestoreBatch)
c.RBLister = c.StashInformerFactory.Stash().V1beta1().RestoreBatches().Lister()
c.RBInformer.AddEventHandler(queue.NewFilteredHandler(queue.NewChangeHandler(c.RBQueue.GetQueue(), c.Controller.RestrictToNamespace), ls))
c.RBInformer.AddEventHandler(queue.NewFilteredHandler(queue.NewChangeHandler(c.RBQueue.GetQueue(), c.restrictToNamespace), ls))
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/initializer/stash/restorebatch.go
Expand Up @@ -31,7 +31,7 @@ func (c *Controller) restoreBatchInformer(tweakListOptions func(options *metav1.
return c.StashInformerFactory.InformerFor(&v1beta1.RestoreBatch{}, func(client scs.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return stashinformers.NewFilteredRestoreBatchInformer(
client,
c.Controller.RestrictToNamespace,
c.restrictToNamespace,
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
tweakListOptions,
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/initializer/stash/restoresession.go
Expand Up @@ -31,7 +31,7 @@ func (c *Controller) restoreSessionInformer(tweakListOptions func(options *metav
return c.StashInformerFactory.InformerFor(&v1beta1.RestoreSession{}, func(client scs.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return stashinformers.NewFilteredRestoreSessionInformer(
client,
c.Controller.RestrictToNamespace,
c.restrictToNamespace,
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
tweakListOptions,
Expand Down
18 changes: 11 additions & 7 deletions pkg/controller/statefulset/controller.go
Expand Up @@ -38,8 +38,14 @@ import (
)

type Controller struct {
*amc.Controller
*amc.Config

// Kubernetes client
Client kubernetes.Interface
// KubeDB client
DBClient db_cs.Interface
// Dynamic client
DynamicClient dynamic.Interface
}

func NewController(
Expand All @@ -49,12 +55,10 @@ func NewController(
dmClient dynamic.Interface,
) *Controller {
return &Controller{
Controller: &amc.Controller{
Client: client,
DBClient: dbClient,
DynamicClient: dmClient,
},
Config: config,
Config: config,
Client: client,
DBClient: dbClient,
DynamicClient: dmClient,
}
}

Expand Down

0 comments on commit a8eb885

Please sign in to comment.