selector

package
v2.0.0-...-98cc131 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchSelectors

func MatchSelectors(obj map[string]string, selectors ...Interface) (bool, error)

MatchSelectors checks whether all selectors matches the given obj.

Types

type DefaultSelector

type DefaultSelector map[string]interface{}

DefaultSelector defines the selector for the identity of an object. The default selector is a map of identity key to selector All keys are validated against the given selector.

Valid selectors are - raw string value: identity value is compared to the selector value - array of strings: or-operator identity value must be one of the defined strings in the array.

func ParseDefaultSelector

func ParseDefaultSelector(value interface{}) (DefaultSelector, error)

ParseDefaultSelector creates a Identity selector from a - json encoded selector - map[string]Selector

A selector can be - a string: the value is directly matched - a array of strings: one selector in the array must match.

func (DefaultSelector) Match

func (is DefaultSelector) Match(obj map[string]string) (bool, error)

type Interface

type Interface interface {
	Match(obj map[string]string) (bool, error)
}

Interface defines a selector interface that matches a map of string to string.

type JSONSchemaSelector

type JSONSchemaSelector struct {
	Scheme *gojsonschema.Schema
}

JSONSchemaSelector uses a jsonschema to match a specific object.

func NewJSONSchemaSelector

func NewJSONSchemaSelector(scheme *gojsonschema.Schema) JSONSchemaSelector

NewJSONSchemaSelector creates a new jsonschema selector from a gojsonschema.

func NewJSONSchemaSelectorFromBytes

func NewJSONSchemaSelectorFromBytes(src []byte) (JSONSchemaSelector, error)

NewJSONSchemaSelectorFromBytes creates a new jsonschema selector from a gojsonschema.

func NewJSONSchemaSelectorFromGoStruct

func NewJSONSchemaSelectorFromGoStruct(src interface{}) (JSONSchemaSelector, error)

NewJSONSchemaSelectorFromString creates a new jsonschema selector from a gojsonschema.

func NewJSONSchemaSelectorFromString

func NewJSONSchemaSelectorFromString(src string) (JSONSchemaSelector, error)

NewJSONSchemaSelectorFromString creates a new jsonschema selector from a gojsonschema.

func (JSONSchemaSelector) Match

func (j JSONSchemaSelector) Match(obj map[string]string) (bool, error)

type RegexSelector

type RegexSelector map[string]interface{}

RegexSelector defines the selector for the identity of an object. The regex selector is a map of identity key to selector All keys are validated against the given selector.

Valid selectors are - raw string value: identity value is compared to the selector value - array of strings: or-operator identity value must be one of the defined strings in the array.

func ParseRegexSelector

func ParseRegexSelector(value interface{}) (RegexSelector, error)

ParseRegexSelector creates a Identity selector from a - json encoded selector - map[string]Selector

A selector can be - a string: the value is directly matched - a array of strings: one selector in the array must match.

func (RegexSelector) Match

func (is RegexSelector) Match(obj map[string]string) (bool, error)

type SelectorFunc

type SelectorFunc func(obj map[string]string) (bool, error)

SelectorFunc describes a function that can be used as selector interface.

func (SelectorFunc) Match

func (s SelectorFunc) Match(obj map[string]string) (bool, error)

Jump to

Keyboard shortcuts

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