listprocessor

package
v0.0.0-...-43fc03f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package listprocessor contains methods for filtering, sorting, and paginating lists of objects.

Index

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

SortList sorts the slice by the provided sort criteria.

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].

func (Filter) String

func (f Filter) String() string

String returns the filter as a query string.

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.

func (OrFilter) String

func (f OrFilter) String() string

String returns the filter as a query string.

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

type Sort struct {
	// contains filtered or unexported fields
}

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.

func (Sort) String

func (s Sort) String() string

String returns the sort parameters as a query string.

type SortOrder

type SortOrder int

SortOrder represents whether the list should be ascending or descending.

const (
	// ASC stands for ascending order.
	ASC SortOrder = iota
	// DESC stands for descending (reverse) order.
	DESC
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL