anchor

package
v1.9.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConditionalAnchorErrMsg = "conditional anchor mismatch"

ConditionalAnchorErrMsg - the error message for conditional anchor error

View Source
var GlobalAnchorErrMsg = "global anchor mismatch"

GlobalAnchorErrMsg - the error message for global anchor error

View Source
var NegationAnchorErrMsg = "negation anchor matched in resource"

NegationAnchorErrMsg - the error message for negation anchor error

Functions

func AddAnchor added in v1.6.0

func AddAnchor(key, anchorPrefix string) string

AddAnchor adds an anchor with the supplied prefix. The suffix is assumed to be ")".

func ContainsCondition added in v1.6.0

func ContainsCondition(str string) bool

ContainsCondition returns true, if str is either condition anchor or global condition anchor

func GetAnchorsResourcesFromMap added in v1.1.0

func GetAnchorsResourcesFromMap(patternMap map[string]interface{}) (map[string]interface{}, map[string]interface{})

GetAnchorsResourcesFromMap returns map of anchors

func IsAddIfNotPresentAnchor added in v1.6.0

func IsAddIfNotPresentAnchor(key string) bool

IsAddIfNotPresentAnchor checks for addition anchor

func IsConditionAnchor

func IsConditionAnchor(str string) bool

IsConditionAnchor checks for condition anchor

func IsConditionalAnchorError added in v1.6.0

func IsConditionalAnchorError(msg string) bool

IsConditionalAnchorError checks if error message has conditional anchor error string

func IsEqualityAnchor

func IsEqualityAnchor(str string) bool

IsEqualityAnchor checks for equality anchor

func IsExistenceAnchor added in v1.6.0

func IsExistenceAnchor(str string) bool

IsExistenceAnchor checks for existence anchor

func IsGlobalAnchor added in v1.6.0

func IsGlobalAnchor(str string) bool

IsGlobalAnchor checks for global condition anchor

func IsGlobalAnchorError added in v1.6.0

func IsGlobalAnchorError(msg string) bool

IsGlobalAnchorError checks if error message has global anchor error string

func IsNegationAnchor

func IsNegationAnchor(str string) bool

IsNegationAnchor checks for negation anchor

func IsNegationAnchorError added in v1.6.0

func IsNegationAnchorError(msg string) bool

IsNegationAnchorError checks if error message has negation anchor error string

func IsNonAnchor added in v1.6.0

func IsNonAnchor(str string) bool

IsNonAnchor checks that key does not have any anchor

func RemoveAnchor added in v1.6.0

func RemoveAnchor(key string) (string, string)

RemoveAnchor remove anchor from the given key. It returns the anchor-free tag value and the prefix of the anchor.

func RemoveAnchorsFromPath added in v1.6.0

func RemoveAnchorsFromPath(str string) string

RemoveAnchorsFromPath removes all anchor from path string

Types

type AnchorError added in v1.6.0

type AnchorError int

AnchorError is the const specification of anchor errors

const (
	// ConditionalAnchorErr refers to condition violation
	ConditionalAnchorErr AnchorError = iota

	// GlobalAnchorErr refers to global condition violation
	GlobalAnchorErr

	// NegationAnchorErr refers to negation violation
	NegationAnchorErr
)

type AnchorKey added in v1.6.0

type AnchorKey struct {

	// AnchorError - used in validate to break execution of the recursion when if condition fails
	AnchorError ValidateAnchorError
	// contains filtered or unexported fields
}

AnchorKey - contains map of anchors

func NewAnchorMap added in v1.6.0

func NewAnchorMap() *AnchorKey

NewAnchorMap -initialize anchorMap

func (*AnchorKey) CheckAnchorInResource added in v1.6.0

func (ac *AnchorKey) CheckAnchorInResource(pattern interface{}, resource interface{})

CheckAnchorInResource checks if condition anchor key has values

func (*AnchorKey) IsAnchorError added in v1.6.0

func (ac *AnchorKey) IsAnchorError() bool

IsAnchorError - if any of the anchor key doesn't exists in the resource then it will return true if any of (key)=false then return IsAnchorError() as true if all the keys exists in the pattern exists in resource then return IsAnchorError() as false

type ConditionAnchorHandler added in v1.1.0

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

ConditionAnchorHandler provides handler for condition anchor

func (ConditionAnchorHandler) Handle added in v1.1.0

func (ch ConditionAnchorHandler) Handle(handler resourceElementHandler, resourceMap map[string]interface{}, originPattern interface{}, ac *AnchorKey) (string, error)

Handle processed condition anchor

type DefaultHandler added in v1.1.0

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

DefaultHandler provides handler for non anchor element

func (DefaultHandler) Handle added in v1.1.0

func (dh DefaultHandler) Handle(handler resourceElementHandler, resourceMap map[string]interface{}, originPattern interface{}, ac *AnchorKey) (string, error)

Handle process non anchor element

type EqualityHandler added in v1.1.0

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

EqualityHandler provides handler for non anchor element

func (EqualityHandler) Handle added in v1.1.0

func (eh EqualityHandler) Handle(handler resourceElementHandler, resourceMap map[string]interface{}, originPattern interface{}, ac *AnchorKey) (string, error)

Handle processed condition anchor

type ExistenceHandler added in v1.2.0

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

ExistenceHandler provides handlers to process exitence anchor handler

func (ExistenceHandler) Handle added in v1.2.0

func (eh ExistenceHandler) Handle(handler resourceElementHandler, resourceMap map[string]interface{}, originPattern interface{}, ac *AnchorKey) (string, error)

Handle processes the existence anchor handler

type GlobalAnchorHandler added in v1.4.3

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

GlobalAnchorHandler provides handler for global condition anchor

func (GlobalAnchorHandler) Handle added in v1.4.3

func (gh GlobalAnchorHandler) Handle(handler resourceElementHandler, resourceMap map[string]interface{}, originPattern interface{}, ac *AnchorKey) (string, error)

Handle processed global condition anchor

type IsAnchor

type IsAnchor func(str string) bool

IsAnchor is a function handler

type NegationHandler added in v1.1.0

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

NegationHandler provides handler for check if the tag in anchor is not defined

func (NegationHandler) Handle added in v1.1.0

func (nh NegationHandler) Handle(handler resourceElementHandler, resourceMap map[string]interface{}, originPattern interface{}, ac *AnchorKey) (string, error)

Handle process negation handler

type ValidateAnchorError added in v1.6.0

type ValidateAnchorError struct {
	Err     AnchorError
	Message string
}

ValidateAnchorError represents the error type of validation anchors

func NewConditionalAnchorError added in v1.6.0

func NewConditionalAnchorError(msg string) ValidateAnchorError

NewConditionalAnchorError returns a new instance of ConditionalAnchorError

func NewGlobalAnchorError added in v1.6.0

func NewGlobalAnchorError(msg string) ValidateAnchorError

NewGlobalAnchorError returns a new instance of GlobalAnchorError

func NewNegationAnchorError added in v1.6.0

func NewNegationAnchorError(msg string) ValidateAnchorError

NewNegationAnchorError returns a new instance of NegationAnchorError

func (ValidateAnchorError) Error added in v1.6.0

func (e ValidateAnchorError) Error() error

Error returns an error instance of the anchor error

func (ValidateAnchorError) IsConditionAnchorError added in v1.6.0

func (e ValidateAnchorError) IsConditionAnchorError() bool

IsConditionAnchorError checks if the error is a conditional anchor error

func (ValidateAnchorError) IsGlobalAnchorError added in v1.6.0

func (e ValidateAnchorError) IsGlobalAnchorError() bool

IsGlobalAnchorError checks if the error is a global anchor error

func (ValidateAnchorError) IsNegationAnchorError added in v1.6.0

func (e ValidateAnchorError) IsNegationAnchorError() bool

IsNegationAnchorError checks if the error is a negation anchor error

func (ValidateAnchorError) IsNil added in v1.6.0

func (e ValidateAnchorError) IsNil() bool

IsNil checks if the error isn't populated

type ValidationHandler added in v1.1.0

type ValidationHandler interface {
	Handle(handler resourceElementHandler, resourceMap map[string]interface{}, originPattern interface{}, ac *AnchorKey) (string, error)
}

ValidationHandler for element processes

func CreateElementHandler added in v1.1.0

func CreateElementHandler(element string, pattern interface{}, path string) ValidationHandler

CreateElementHandler factory to process elements

func NewConditionAnchorHandler added in v1.1.0

func NewConditionAnchorHandler(anchor string, pattern interface{}, path string) ValidationHandler

NewConditionAnchorHandler returns an instance of condition acnhor handler

func NewDefaultHandler added in v1.1.0

func NewDefaultHandler(element string, pattern interface{}, path string) ValidationHandler

NewDefaultHandler returns handler for non anchor elements

func NewEqualityHandler added in v1.1.0

func NewEqualityHandler(anchor string, pattern interface{}, path string) ValidationHandler

NewEqualityHandler returens instance of equality handler

func NewExistenceHandler added in v1.2.0

func NewExistenceHandler(anchor string, pattern interface{}, path string) ValidationHandler

NewExistenceHandler returns existence handler

func NewGlobalAnchorHandler added in v1.4.3

func NewGlobalAnchorHandler(anchor string, pattern interface{}, path string) ValidationHandler

NewGlobalAnchorHandler returns an instance of condition acnhor handler

func NewNegationHandler added in v1.1.0

func NewNegationHandler(anchor string, pattern interface{}, path string) ValidationHandler

NewNegationHandler returns instance of negation handler

Jump to

Keyboard shortcuts

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