Documentation ¶
Overview ¶
Package env provides an environment for managing variable frames in an interpreter context, using a stack-based approach.
Index ¶
- type Env
- func (e *Env) GetCurrentFrame() *Frame
- func (e *Env) GetVar(name string) (interface{}, bool)
- func (e *Env) LookupAll(expression string, allowMissingKeys bool) ([]interface{}, error)
- func (e *Env) LookupFirst(expression string) (interface{}, error)
- func (e *Env) Pop()
- func (e *Env) Push(newVars map[string]interface{})
- func (e *Env) With(newVars map[string]interface{}, f func() error) error
- type EnvOption
- type Frame
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env represents an environment with a stack of variable frames. It allows pushing and popping frames and querying variables.
func NewEnv ¶
NewEnv creates a new environment for managing variable frames. It accepts optional EnvOptions to configure the initial state.
func (*Env) GetCurrentFrame ¶
GetCurrentFrame returns the current top frame from the stack. Returns nil if the stack is empty.
func (*Env) GetVar ¶
GetVar tries to retrieve a variable's value by its name from the current frame. Returns the value and a boolean indicating if the variable was found. If the stack is empty, it returns nil and false.
func (*Env) LookupAll ¶
LookupAll performs a jsonpath query on the variables of the current frame. It returns all matches as a slice of interface{} and an error if the query fails or if the current frame is nil. The function requires a valid jsonpath expression and uses the Kubernetes jsonpath package.
func (*Env) LookupFirst ¶
LookupFirst performs a jsonpath query on the variables of the current frame. It returns the first match as an interface{} and an error if the query fails or if the current frame is nil, or if no matching node is found.
func (*Env) Pop ¶
func (e *Env) Pop()
Pop removes the top frame from the stack. It does nothing if the stack is empty.