utils

package
v0.4.11-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultJSONPathParser = NewJSONPathParser()

Functions

func RelaxedJSONPathExpression

func RelaxedJSONPathExpression(pathExpression string) (string, error)

copied from kubectl

Types

type ESImporter

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

ESImporter is the struct responsible for importing data to an Elasticsearch storage.

func NewESImporter

func NewESImporter(esClient *elasticsearch.Storage, cluster string, gvr schema.GroupVersionResource) *ESImporter

NewESImporter creates a new instance of the ESImporter struct with the provided Elasticsearch client, cluster name, and GroupVersionResource.

func (*ESImporter) ImportTo

func (e *ESImporter) ImportTo(ctx context.Context, store cache.Store) error

ImportTo implements the Importer interface by importing data to the specified cache.Store within the given context. The method should be implemented to perform the actual data import.

type ESListerGetter

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

func NewESListerGetter

func NewESListerGetter(cluster string, esClient *elasticsearch.Storage, gvr schema.GroupVersionResource) *ESListerGetter

NewESListerGetter creates a new instance of the ESListerGetter with the provided cluster name, Elasticsearch client, and GroupVersionResource.

func (*ESListerGetter) GetByKey

func (e *ESListerGetter) GetByKey(key string) (value interface{}, exists bool, err error)

GetByKey retrieves the value associated with the provided key from the managed resources.

func (*ESListerGetter) ListKeys

func (e *ESListerGetter) ListKeys() []string

ListKeys returns a list of keys for the resources managed by the ESListerGetter.

type FieldsSelector

type FieldsSelector struct {
	fields.Selector
	ServerSupported bool
}

FieldsSelector represents a selection based on fields.

func (FieldsSelector) Empty

func (fs FieldsSelector) Empty() bool

Empty checks if the FieldsSelector is empty, meaning no fields are specified for selection.

type Importer

type Importer interface {
	ImportTo(ctx context.Context, store cache.Store) error
}

Importer defines the interface for importing data to a specified storage.

type JSONPathFields

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

JSONPathFields is a struct that holds a JSONPathParser instance and the data to be queried by JSONPath expressions.

func NewJSONPathFields

func NewJSONPathFields(jpParser *JSONPathParser, data interface{}) *JSONPathFields

NewJSONPathFields creates and returns a new instance of JSONPathFields with the given parser and data.

func (JSONPathFields) Get

func (fs JSONPathFields) Get(fieldPath string) (value string)

Get retrieves the value at the specified JSONPath expression from the data and returns it as a string.

func (JSONPathFields) Has

func (fs JSONPathFields) Has(fieldPath string) (exists bool)

Has checks if the given JSONPath expression exists in the data, returning a boolean indicating its existence.

type JSONPathParser

type JSONPathParser struct {
	sync.Mutex
	// contains filtered or unexported fields
}

JSONPathParser is a struct that holds a cache of parsed JSONPath expressions for efficient reuse.

func NewJSONPathParser

func NewJSONPathParser() *JSONPathParser

NewJSONPathParser creates and returns a new instance of JSONPathParser with an empty cache.

func (*JSONPathParser) Parse

func (j *JSONPathParser) Parse(path string) (*jsonpath.JSONPath, error)

Parse takes a JSONPath expression string and returns a parsed JSONPath object or an error if the expression is invalid.

type MultiSelectors

type MultiSelectors []Selector

MultiSelectors is a slice of Selectors, allowing for multiple selection criteria to be combined.

func (MultiSelectors) ApplyToList

func (m MultiSelectors) ApplyToList(options *metav1.ListOptions)

ApplyToList applies the MultiSelectors to the provided metav1.ListOptions for use in Kubernetes API list requests.

func (MultiSelectors) Matches

func (m MultiSelectors) Matches(obj Selectable) bool

Matches checks if the provided Selectable object matches any of the selection criteria specified in the MultiSelectors.

func (MultiSelectors) Predicate

func (m MultiSelectors) Predicate(obj interface{}) bool

Predicate returns a function that implements the Predicate interface, allowing the MultiSelectors to be used as a go-restful Predicate.

type Selectable

type Selectable interface {
	GetLabels() labels.Labels
	GetFields() fields.Fields
}

Selectable defines the interface for objects that can be selected by labels and fields.

type Selector

type Selector struct {
	Label labels.Selector
	Field FieldsSelector
}

Selector represents a selection based on labels and fields.

func (Selector) Matches

func (s Selector) Matches(obj Selectable) bool

Matches checks if the provided Selectable object matches the selection criteria specified by the Selector.

func (Selector) ServerSupported

func (s Selector) ServerSupported() bool

ServerSupported checks if the server supports the fields and labels specified in the Selector.

Jump to

Keyboard shortcuts

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