Skip to content

Commit

Permalink
Merge pull request #578 from estroz/options-selector
Browse files Browse the repository at this point in the history
✨ pkg/client/options.go: MatchingSelector can add a fields.Selector to ListOptions
  • Loading branch information
k8s-ci-robot committed Sep 9, 2019
2 parents e9f3cfc + 940797e commit 6993406
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion pkg/client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,21 @@ func (m MatchingLabels) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
m.ApplyToList(&opts.ListOptions)
}

// MatchingLabelsSelector filters the list/delete operation on the given label
// selector (or index in the case of cached lists). A struct is used because
// labels.Selector is an interface, which cannot be aliased.
type MatchingLabelsSelector struct {
labels.Selector
}

func (m MatchingLabelsSelector) ApplyToList(opts *ListOptions) {
opts.LabelSelector = m
}

func (m MatchingLabelsSelector) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
m.ApplyToList(&opts.ListOptions)
}

// MatchingField filters the list operation on the given field selector
// (or index in the case of cached lists).
//
Expand All @@ -321,7 +336,7 @@ func MatchingField(name, val string) MatchingFields {
return MatchingFields{name: val}
}

// MatchingField filters the list/delete operation on the given field selector
// MatchingField filters the list/delete operation on the given field Set
// (or index in the case of cached lists).
type MatchingFields fields.Set

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

// MatchingFieldsSelector filters the list/delete operation on the given field
// selector (or index in the case of cached lists). A struct is used because
// fields.Selector is an interface, which cannot be aliased.
type MatchingFieldsSelector struct {
fields.Selector
}

func (m MatchingFieldsSelector) ApplyToList(opts *ListOptions) {
opts.FieldSelector = m
}

func (m MatchingFieldsSelector) ApplyToDeleteAllOf(opts *DeleteAllOfOptions) {
m.ApplyToList(&opts.ListOptions)
}

// InNamespace restricts the list/delete operation to the given namespace.
type InNamespace string

Expand Down

0 comments on commit 6993406

Please sign in to comment.