Documentation ¶
Index ¶
Constants ¶
const ( // StringMapHasKey passes if the map has the provided key StringMapHasKey StringMapOperation = "stringmapcontains" StringMapStartsWith = "stringmapstartswith" // StringMapEquals when the given key and value match StringMapEquals = "stringmapequals" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllCut ¶
type AllCut[T any] struct{}
AllCut is a filter that matches nothing. This is useful for applications like authorization, where a user/group/role may be disallowed from viewing data entirely.
type AllPass ¶
type AllPass[T any] struct{}
AllPass is a filter that matches everything and is the same as no filter. It is implemented here as a guard against universal operations occurring in the absence of filters.
type Filter ¶
type Filter[T any] interface { String() string // Matches is the canonical in-Go function for determining if T // matches a filter. Matches(T) bool }
Filter represents anything that can be used to filter given generic type T.
Implement this interface with caution. While it is generic, it is intended to be introspectable so query handlers can perform various optimizations. These optimizations include: - Routing a query to the most optimal cache - Querying backing data stores efficiently (e.g. translation to SQL)
Custom implementations of this interface outside of this package should not expect to receive these benefits. Passing a custom implementation to a handler may in errors.
type Not ¶
Not negates any filter contained within it
type StringMapOperation ¶
type StringMapOperation string
StringMapOperation is an enum that represents operations that can be performed when filtering (equality, inequality, etc.)
type StringMapPropertied ¶
type StringMapProperty ¶
type StringMapProperty[T StringMapPropertied] struct { Field string Op StringMapOperation Key string Value string }
StringMapProperty is the lowest-level type of filter. It represents a filter operation (equality, inequality, etc.) on a property that contains a string map
func (StringMapProperty[T]) Matches ¶
func (smp StringMapProperty[T]) Matches(that T) bool
func (StringMapProperty[T]) String ¶
func (smp StringMapProperty[T]) String() string
type StringOperation ¶
type StringOperation string
StringOperation is an enum that represents operations that can be performed when filtering (equality, inequality, etc.)
const ( // StringEquals is the equality operator // "kube-system" FilterEquals "kube-system" = true // "kube-syste" FilterEquals "kube-system" = false StringEquals StringOperation = "stringequals" // StringStartsWith matches strings with the given prefix. // "kube-system" StartsWith "kube" = true // // When comparing with a field represented by an array/slice, this is like // applying FilterContains to every element of the slice. StringStartsWith = "stringstartswith" )
If you add a FilterOp, MAKE SURE TO UPDATE ALL FILTER IMPLEMENTATIONS! Go does not enforce exhaustive pattern matching on "enum" types.
type StringPropertied ¶
type StringPropertied interface { // StringProperty acts as a validator and getter for a structs string properties StringProperty(string) (string, error) }
StringPropertied is used to validate the name of a property field and return its value
type StringProperty ¶
type StringProperty[T StringPropertied] struct { Field string Op StringOperation // Value is for _all_ filters. A filter of 'namespace:"kubecost"' has // Value="kubecost" Value string }
StringProperty is the lowest-level type of filter. It represents a filter operation (equality, inequality, etc.) on a field with a string value (namespace, node, pod, etc.).
func (StringProperty[T]) Matches ¶
func (sp StringProperty[T]) Matches(that T) bool
func (StringProperty[T]) String ¶
func (sp StringProperty[T]) String() string
type StringSliceOperation ¶
type StringSliceOperation string
StringSliceOperation is an enum that represents operations that can be performed when filtering (equality, inequality, etc.)
const ( // StringSliceContains is an array/slice membership operator // ["a", "b", "c"] FilterContains "a" = true StringSliceContains StringSliceOperation = "stringslicecontains" // StringSliceContainsPrefix is like FilterContains, but using StartsWith instead // of Equals. // ["kube-system", "abc123"] ContainsPrefix ["kube"] = true StringSliceContainsPrefix = "stringslicecontainsprefix" )
type StringSlicePropertied ¶
type StringSliceProperty ¶
type StringSliceProperty[T StringSlicePropertied] struct { Field string Op StringSliceOperation Value string }
StringSliceProperty is the lowest-level type of filter. It represents a filter operation (equality, inequality, etc.) on a property that contains a string slice
func (StringSliceProperty[T]) Matches ¶
func (ssp StringSliceProperty[T]) Matches(that T) bool
func (StringSliceProperty[T]) String ¶
func (ssp StringSliceProperty[T]) String() string