<p>Im trying to listen to secret change using the operator sdk
The problem is that im not getting the reconcile event when I apply the secret with the labels that I define in the operator</p>
<p>I did the following</p>
<pre><code>mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
    Scheme:                 scheme,
        …
    NewCache: cache.BuilderWithOptions(cache.Options{
        SelectorsByObject: cache.SelectorsByObject{
            &amp;corev1.Secret{}: {
                Label: labels.SelectorFromSet(labels.Set{&quot;foo&quot;: &quot;bar&quot;}),
            },
        },
    }),
</code></pre>
<p>I run the operator and apply the following secret and the <strong>reconcile is not invoked</strong>, any idea?</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
  labels:
    foo: bar
  name: mysecret
  namespace: dev
type: Opaque
data:
  USER_NAME: YWRtaW4=
  PASSWORD: dGVzdBo=
</code></pre>

PJEM
<p>It looks like you are using the cache.Options.SelectorsByObject field to specify the labels that should trigger a reconcile event. However, this field is used to specify the labels that should be used to select objects from the cache, not the labels that should trigger a reconcile event.</p>
<p>To specify the labels that should trigger a reconcile event, you can use the ctrl.Watch function, like this:</p>
<pre class="lang-golang prettyprint-override"><code>mgr.Watch(&amp;source.Kind{Type: &amp;corev1.Secret{}},
    &amp;handler.EnqueueRequestForObject{},
    predicate.Funcs{
        UpdateFunc: func(e event.UpdateEvent) bool {
            return labels.Set(e.MetaNew.GetLabels()).Has(&quot;foo&quot;, &quot;bar&quot;)
        },
    })
</code></pre>
