resolve

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: BSD-3-Clause Imports: 5 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomDereferenceCleaner

func CustomDereferenceCleaner(f DereferenceCleaner) func(*basicResolver)

func GetResolverInfo

func GetResolverInfo(toResolve string) (string, int)

GetResolverInfo gets the resolver name and position to start parsing the ResolutionDetails from

func IsResolveExpr

func IsResolveExpr(exprStr string) bool

IsResolveExpr determines if the provide expression string is a resolver expression, ie. "$env[MY_VAR]

func NoDereferencing

func NoDereferencing(r *basicResolver)

func OptImplicit added in v0.0.7

func OptImplicit(r *ResolverInfo)

func OptStatic added in v0.0.7

func OptStatic(r *ResolverInfo)

func OptUseItemFormat added in v0.0.7

func OptUseItemFormat(r *ResolverInfo)

Types

type CompositeResolver

type CompositeResolver interface {
	// GetResolution creates a "delayed" resolution object, who's value isn't fully resolved
	// util GetValue is called
	GetResolution(resolveDirective string) (Resolution, error)

	// Resolve resolves to a value using the specified directive
	Resolve(resolveDirective string, scope data.Scope) (value interface{}, err error)
}

CompositeResolver is a resolver that is typically composed of other simple 'Resolvers', the specified directive is dispatched to the appropriate embedded resolvers

func GetBasicResolver

func GetBasicResolver() CompositeResolver

func NewCompositeResolver

func NewCompositeResolver(resolvers map[string]Resolver, options ...func(r *basicResolver)) CompositeResolver

type DereferenceCleaner

type DereferenceCleaner func(string) (string, bool)

DereferenceCleaner removes the dereference characters from the resolve directive

type EnvResolver

type EnvResolver struct {
}

func (*EnvResolver) GetResolverInfo

func (*EnvResolver) GetResolverInfo() *ResolverInfo

func (*EnvResolver) Resolve

func (*EnvResolver) Resolve(scope data.Scope, item string, field string) (interface{}, error)

EnvResolver Environment Resolver $env[item]

type LoopResolver

type LoopResolver struct {
}

func (*LoopResolver) GetResolverInfo

func (*LoopResolver) GetResolverInfo() *ResolverInfo

func (*LoopResolver) Resolve

func (*LoopResolver) Resolve(scope data.Scope, item string, field string) (interface{}, error)

LoopResolver Loop Resolver $Loop[item]

type Option added in v0.0.7

type Option func(*ResolverInfo)

type Resolution

type Resolution interface {
	// IsStatic indicates that resolution can be done statically without a scope
	IsStatic() bool

	// GetValue resolves and returns the value using the specified scope
	GetValue(scope data.Scope) (interface{}, error)
}

Resolution structure that is allows for delayed resolving of values, the value can then be fully resolved calling GetValue for a particular scope

type ResolveDirectiveDetails

type ResolveDirectiveDetails struct {
	ItemName  string
	ValueName string
	Path      string
}

ResolveDirectiveDetails is the Resolve Directive broken into components to assist in resolving the value

func GetResolveDirectiveDetails

func GetResolveDirectiveDetails(directive string, hasItems, isImplicit bool) (*ResolveDirectiveDetails, error)

GetResolveDirectiveDetails breaks Resolution Directive into components

type Resolver

type Resolver interface {
	// GetResolverInfo returns ResolverInfo which contains information about the resolver
	GetResolverInfo() *ResolverInfo

	// Resolve resolves to a value using the specified item and valueName, note: the scope might not be used
	Resolve(scope data.Scope, itemName, valueName string) (interface{}, error)
}

Resolver is for resolving a value for a specific environment or construct, ex. OS environment

type ResolverInfo

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

ResolverInfo structure that contains information about the resolver

func CreateResolverInfo added in v0.0.7

func CreateResolverInfo(options ...Option) *ResolverInfo

func NewImplicitResolverInfo

func NewImplicitResolverInfo(isStatic, isImplicit bool) *ResolverInfo

func NewResolverInfo

func NewResolverInfo(isStatic, usesItemFormat bool) *ResolverInfo

NewResolverInfo creates a ResolverInfo object

func (*ResolverInfo) IsImplicit

func (i *ResolverInfo) IsImplicit() bool

IsImplicit determines if the resolver try to uses the item format and no item format then

func (*ResolverInfo) IsStatic

func (i *ResolverInfo) IsStatic() bool

IsStatic determines if the resolver's values are static and can be resolved immediately without a scope

func (*ResolverInfo) UsesItemFormat

func (i *ResolverInfo) UsesItemFormat() bool

UsesItemFormat determines if the resolver uses the item format (ex. $test[itemName])

type ScopeResolver

type ScopeResolver struct {
}

func (*ScopeResolver) GetResolverInfo

func (*ScopeResolver) GetResolverInfo() *ResolverInfo

func (*ScopeResolver) Resolve

func (*ScopeResolver) Resolve(scope data.Scope, item string, field string) (interface{}, error)

ScopeResolver Scope Resolver $.

Jump to

Keyboard shortcuts

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