Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidFilterParams describes an error where invalid parameters were given // to a filter. ErrInvalidFilterParams = errors.New("invalid parameters given to filter") )
Functions ¶
This section is empty.
Types ¶
type ListFilter ¶ added in v0.0.3
type ListFilter interface {
// Filter walks through all objects in obj, assesses whether the object
// matches the filter parameters, and conditionally adds it to the return
// slice or not. This method can be thought of like an UNIX pipe.
Filter(objs ...runtime.Object) ([]runtime.Object, error)
}
ListFilter is an interface for pipe-like list filtering behavior.
func ObjectToListFilter ¶ added in v0.0.3
func ObjectToListFilter(of ObjectFilter) ListFilter
ObjectToListFilter transforms an ObjectFilter into a ListFilter. If of is nil, this function panics.
type ListOption ¶ added in v0.0.3
type ListOption interface {
// ApplyToListOptions applies the configuration of the current object into a target ListOptions struct.
ApplyToListOptions(target *ListOptions) error
}
ListOption is an interface which can be passed into e.g. List() methods as a variadic-length argument list.
type ListOptions ¶ added in v0.0.3
type ListOptions struct {
// Filters contains a chain of ListFilters, which will be processed in order and pipe the
// available objects through before returning.
Filters []ListFilter
}
ListOptions is a generic struct for listing options.
func MakeListOptions ¶ added in v0.0.3
func MakeListOptions(opts ...ListOption) (*ListOptions, error)
MakeListOptions makes a completed ListOptions struct from a list of ListOption implementations.
type NameFilter ¶
type NameFilter struct {
// Name matches the object by .metadata.name.
// +required
Name string
// Namespace matches the object by .metadata.namespace. If left as
// an empty string, it is ignored when filtering.
// +optional
Namespace string
// MatchPrefix whether the name (not namespace) matching should be exact, or prefix-based.
// +optional
MatchPrefix bool
}
NameFilter is an ObjectFilter that compares runtime.Object.GetName() to the Name field by either equality or prefix.
func (NameFilter) ApplyToListOptions ¶ added in v0.0.3
func (f NameFilter) ApplyToListOptions(target *ListOptions) error
ApplyToListOptions implements ListOption, and adds itself converted to a ListFilter to ListOptions.Filters.
type ObjectFilter ¶ added in v0.0.3
type ObjectFilter interface {
// Filter takes in one object (at once, per invocation), and returns a
// boolean whether the object matches the filter parameters, or not.
Filter(obj runtime.Object) (bool, error)
}
ObjectFilter is an interface for filtering objects one-by-one.
type UIDFilter ¶ added in v0.0.3
type UIDFilter struct {
// UID matches the object by .metadata.uid.
// +required
UID types.UID
// MatchPrefix whether the UID-matching should be exact, or prefix-based.
// +optional
MatchPrefix bool
}
UIDFilter is an ObjectFilter that compares runtime.Object.GetUID() to the UID field by either equality or prefix. The UID field is required, otherwise ErrInvalidFilterParams is returned.
func (UIDFilter) ApplyToListOptions ¶ added in v0.0.3
func (f UIDFilter) ApplyToListOptions(target *ListOptions) error
ApplyToListOptions implements ListOption, and adds itself converted to a ListFilter to ListOptions.Filters.