From e7d1690d2703f26b2f7f81ce93f7b831328c7f60 Mon Sep 17 00:00:00 2001 From: Richard Kojedzinszky Date: Fri, 15 Dec 2023 14:30:35 +0100 Subject: [PATCH] fix(context): ListOption() use namespace in returned ListOption --- private/context/context.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/private/context/context.go b/private/context/context.go index a126d12..025f732 100644 --- a/private/context/context.go +++ b/private/context/context.go @@ -29,6 +29,7 @@ import ( gocontext "context" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/kubernetes" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" @@ -92,7 +93,10 @@ func (c *context) CommonLabels() (ret map[string]string) { // ListOption returns filter matching owned objects func (c *context) ListOption() (lo client.ListOption, err error) { - return client.MatchingLabels(c.CommonLabels()), nil + return &client.ListOptions{ + Namespace: c.pp.Namespace, + LabelSelector: labels.SelectorFromSet(c.CommonLabels()), + }, nil } func (c *context) SetMeta(m metav1.Object) error {