2017-09-11 23:40:37 +00:00
|
|
|
package hcl
|
2017-05-20 22:17:56 +00:00
|
|
|
|
|
|
|
import (
|
2017-05-28 00:35:44 +00:00
|
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
"github.com/zclconf/go-cty/cty/function"
|
2017-05-20 22:17:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// An EvalContext provides the variables and functions that should be used
|
|
|
|
// to evaluate an expression.
|
|
|
|
type EvalContext struct {
|
|
|
|
Variables map[string]cty.Value
|
|
|
|
Functions map[string]function.Function
|
|
|
|
parent *EvalContext
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewChild returns a new EvalContext that is a child of the receiver.
|
|
|
|
func (ctx *EvalContext) NewChild() *EvalContext {
|
|
|
|
return &EvalContext{parent: ctx}
|
|
|
|
}
|
2017-06-16 14:28:29 +00:00
|
|
|
|
|
|
|
// Parent returns the parent of the receiver, or nil if the receiver has
|
|
|
|
// no parent.
|
|
|
|
func (ctx *EvalContext) Parent() *EvalContext {
|
|
|
|
return ctx.parent
|
|
|
|
}
|