Skip to content

Commit b841aee

Browse files
estrozmszostok
authored andcommitted
pkg/client/options.go: MatchingFieldsSelector and MatchingLabelsSelector
are wrapper types for fields.Selector and labels.Selector, respectively, implementing ListOption and DeleteAllOfOption
1 parent 606948f commit b841aee

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

pkg/client/options.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,21 @@ func (m MatchingLabels) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
313313
m.ApplyToList(&opts.ListOptions)
314314
}
315315

316+
// MatchingLabelsSelector filters the list/delete operation on the given label
317+
// selector (or index in the case of cached lists). A struct is used because
318+
// labels.Selector is an interface, which cannot be aliased.
319+
type MatchingLabelsSelector struct {
320+
labels.Selector
321+
}
322+
323+
func (m MatchingLabelsSelector) ApplyToList(opts *ListOptions) {
324+
opts.LabelSelector = m
325+
}
326+
327+
func (m MatchingLabelsSelector) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
328+
m.ApplyToList(&opts.ListOptions)
329+
}
330+
316331
// MatchingField filters the list operation on the given field selector
317332
// (or index in the case of cached lists).
318333
//
@@ -321,7 +336,7 @@ func MatchingField(name, val string) MatchingFields {
321336
return MatchingFields{name: val}
322337
}
323338

324-
// MatchingField filters the list/delete operation on the given field selector
339+
// MatchingField filters the list/delete operation on the given field Set
325340
// (or index in the case of cached lists).
326341
type MatchingFields fields.Set
327342

@@ -335,6 +350,21 @@ func (m MatchingFields) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
335350
m.ApplyToList(&opts.ListOptions)
336351
}
337352

353+
// MatchingFieldsSelector filters the list/delete operation on the given field
354+
// selector (or index in the case of cached lists). A struct is used because
355+
// fields.Selector is an interface, which cannot be aliased.
356+
type MatchingFieldsSelector struct {
357+
fields.Selector
358+
}
359+
360+
func (m MatchingFieldsSelector) ApplyToList(opts *ListOptions) {
361+
opts.FieldSelector = m
362+
}
363+
364+
func (m MatchingFieldsSelector) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
365+
m.ApplyToList(&opts.ListOptions)
366+
}
367+
338368
// InNamespace restricts the list/delete operation to the given namespace.
339369
type InNamespace string
340370

0 commit comments

Comments
 (0)