Documentation
¶
Overview ¶
Package listprocessor contains methods for filtering, sorting, and paginating lists of objects.
Index ¶
- func FilterByProjectsAndNamespaces(list []unstructured.Unstructured, ...) []unstructured.Unstructured
- func FilterList(list <-chan []unstructured.Unstructured, filters []OrFilter) []unstructured.Unstructured
- func PaginateList(list []unstructured.Unstructured, p Pagination) ([]unstructured.Unstructured, int)
- func SortList(list []unstructured.Unstructured, s Sort) []unstructured.Unstructured
- type Filter
- type ListOptions
- type OrFilter
- type Pagination
- type ProjectsOrNamespacesFilter
- type Sort
- type SortOrder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterByProjectsAndNamespaces ¶
func FilterByProjectsAndNamespaces(list []unstructured.Unstructured, projectsOrNamespaces ProjectsOrNamespacesFilter, namespaceCache corecontrollers.NamespaceCache) []unstructured.Unstructured
func FilterList ¶
func FilterList(list <-chan []unstructured.Unstructured, filters []OrFilter) []unstructured.Unstructured
FilterList accepts a channel of unstructured objects and a slice of filters and returns the filtered list. Filters are ANDed together.
func PaginateList ¶
func PaginateList(list []unstructured.Unstructured, p Pagination) ([]unstructured.Unstructured, int)
PaginateList returns a subset of the result based on the pagination criteria as well as the total number of pages the caller can expect.
func SortList ¶
func SortList(list []unstructured.Unstructured, s Sort) []unstructured.Unstructured
SortList sorts the slice by the provided sort criteria. Convert the sorted list so we calculate the sort values only once per node, making this an O(n) operation rather than an O(n**2) one.
list of u.U => list of { *u.U, []stringValues } => sorted list of { *u.U, []stringValues } => final list of u.U from the above sorted list
We do this because it's much faster to compare two string arrays then to compare the string arrays based on walking objects repeatedly
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter represents a field to filter by. A subfield in an object is represented in a request query using . notation, e.g. 'metadata.name'. The subfield is internally represented as a slice, e.g. [metadata, name].
type ListOptions ¶
type ListOptions struct {
ChunkSize int
Resume string
Filters []OrFilter
Sort Sort
Pagination Pagination
Revision string
ProjectsOrNamespaces ProjectsOrNamespacesFilter
}
ListOptions represents the query parameters that may be included in a list request.
func ParseQuery ¶
func ParseQuery(apiOp *types.APIRequest) *ListOptions
ParseQuery parses the query params of a request and returns a ListOptions.
type OrFilter ¶
type OrFilter struct {
// contains filtered or unexported fields
}
OrFilter represents a set of possible fields to filter by, where an item may match any filter in the set to be included in the result.
type Pagination ¶
type Pagination struct {
// contains filtered or unexported fields
}
Pagination represents how to return paginated results.
func (Pagination) PageSize ¶
func (p Pagination) PageSize() int
PageSize returns the integer page size.
type ProjectsOrNamespacesFilter ¶
type ProjectsOrNamespacesFilter struct {
// contains filtered or unexported fields
}
type Sort ¶
Sort represents the criteria to sort on. The subfield to sort by is represented in a request query using . notation, e.g. 'metadata.name'. The subfield is internally represented as a slice, e.g. [metadata, name]. The order is represented by prefixing the sort key by '-', e.g. sort=-metadata.name.