diff --git a/internal/pkg/controller/controller.go b/internal/pkg/controller/controller.go index 848a59f..eb1823c 100644 --- a/internal/pkg/controller/controller.go +++ b/internal/pkg/controller/controller.go @@ -42,7 +42,8 @@ func NewController( listWatcher := cache.NewListWatchFromClient(client.ExtensionsV1beta1().RESTClient(), resource, namespace, fields.Everything()) indexer, informer := cache.NewIndexerInformer(listWatcher, kube.ResourceMap[resource], 0, cache.ResourceEventHandlerFuncs{ - AddFunc: c.Add, + AddFunc: c.Add, + UpdateFunc: c.Update, }, cache.Indexers{}) c.indexer = indexer c.informer = informer @@ -57,6 +58,13 @@ func (c *Controller) Add(obj interface{}) { }) } +// Add function to add a new object to the queue in case of creating a resource +func (c *Controller) Update(old interface{}, new interface{}) { + c.queue.Add(handler.ResourceCreatedHandler{ + Resource: new, + }) +} + //Run function for controller which handles the queue func (c *Controller) Run(threadiness int, stopCh chan struct{}) {