mirror of
https://github.com/opentofu/opentofu.git
synced 2026-04-15 22:00:12 -04:00
So far all of our language experiments have been new constructs handled statically up in the configs package, but functions are another common extention point where experiments could be useful to gather feedback and so this intends to pass the information down into the right place to allow for that to happen, even though as of this commit there are no experimental functions to use it.
47 lines
1.6 KiB
Go
47 lines
1.6 KiB
Go
package lang
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/zclconf/go-cty/cty/function"
|
|
|
|
"github.com/hashicorp/terraform/addrs"
|
|
"github.com/hashicorp/terraform/experiments"
|
|
)
|
|
|
|
// Scope is the main type in this package, allowing dynamic evaluation of
|
|
// blocks and expressions based on some contextual information that informs
|
|
// which variables and functions will be available.
|
|
type Scope struct {
|
|
// Data is used to resolve references in expressions.
|
|
Data Data
|
|
|
|
// SelfAddr is the address that the "self" object should be an alias of,
|
|
// or nil if the "self" object should not be available at all.
|
|
SelfAddr addrs.Referenceable
|
|
|
|
// BaseDir is the base directory used by any interpolation functions that
|
|
// accept filesystem paths as arguments.
|
|
BaseDir string
|
|
|
|
// PureOnly can be set to true to request that any non-pure functions
|
|
// produce unknown value results rather than actually executing. This is
|
|
// important during a plan phase to avoid generating results that could
|
|
// then differ during apply.
|
|
PureOnly bool
|
|
|
|
funcs map[string]function.Function
|
|
funcsLock sync.Mutex
|
|
|
|
// activeExperiments is an optional set of experiments that should be
|
|
// considered as active in the module that this scope will be used for.
|
|
// Callers can populate it by calling the SetActiveExperiments method.
|
|
activeExperiments experiments.Set
|
|
}
|
|
|
|
// SetActiveExperiments allows a caller to declare that a set of experiments
|
|
// is active for the module that the receiving Scope belongs to, which might
|
|
// then cause the scope to activate some additional experimental behaviors.
|
|
func (s *Scope) SetActiveExperiments(active experiments.Set) {
|
|
s.activeExperiments = active
|
|
}
|