<p>I am trying to get some secret objects from my cluster using the <code>k8s</code> <code>go</code> client library as follows</p>
<pre><code>secret, err := clientset.CoreV1().Secrets(&quot;mynamespace&quot;).Get(&quot;name-of-my-secret&quot;, metav1.GetOptions{})
</code></pre>
<p>This worked well as long as I had to get just one object.</p>
<p>I have a case now where I need to fetch several such secret objects, however this now has to be done based on labels. (i.e. fetch all such secret objects matching the <code>foo=someprovider.someurl.com/path1=value1</code> label)</p>
<p>I don't see however in the relevant <a href="https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#GetOptions" rel="nofollow noreferrer">docs</a> a way to pass label selectors to the <code>GetOptions</code> struct that I assume performs such kind of filtering.</p>
<p>Any suggestions on how to select (potentially multiple) such resources based on labels?</p>

<pre><code>clientset.CoreV1().Secrets(&quot;&quot;).List(context.TODO(), metav1.ListOptions{LabelSelector: &quot;k8s-app=kube-proxy&quot;})
</code></pre>
