From 58640d11ae2f373bc407e2fbd0297ce499a63abf Mon Sep 17 00:00:00 2001 From: Vince Prignano Date: Tue, 18 Apr 2023 09:56:24 -0700 Subject: [PATCH] Add client.InNamespace("xyz").AsSelector() Mostly sugar, but useful in some cases. Signed-off-by: Vince Prignano --- pkg/client/options.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/client/options.go b/pkg/client/options.go index 14578f9140..50a461f1cc 100644 --- a/pkg/client/options.go +++ b/pkg/client/options.go @@ -606,6 +606,11 @@ func (n InNamespace) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) { n.ApplyToList(&opts.ListOptions) } +// AsSelector returns a selector that matches objects in the given namespace. +func (n InNamespace) AsSelector() fields.Selector { + return fields.SelectorFromSet(fields.Set{"metadata.namespace": string(n)}) +} + // Limit specifies the maximum number of results to return from the server. // Limit does not implement DeleteAllOfOption interface because the server // does not support setting it for deletecollection operations.