github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/lang/scope.go (about)

     1  package lang
     2  
     3  import (
     4  	"sync"
     5  
     6  	"github.com/zclconf/go-cty/cty/function"
     7  
     8  	"github.com/hashicorp/terraform/internal/addrs"
     9  	"github.com/hashicorp/terraform/internal/experiments"
    10  )
    11  
    12  // Scope is the main type in this package, allowing dynamic evaluation of
    13  // blocks and expressions based on some contextual information that informs
    14  // which variables and functions will be available.
    15  type Scope struct {
    16  	// Data is used to resolve references in expressions.
    17  	Data Data
    18  
    19  	// SelfAddr is the address that the "self" object should be an alias of,
    20  	// or nil if the "self" object should not be available at all.
    21  	SelfAddr addrs.Referenceable
    22  
    23  	// BaseDir is the base directory used by any interpolation functions that
    24  	// accept filesystem paths as arguments.
    25  	BaseDir string
    26  
    27  	// PureOnly can be set to true to request that any non-pure functions
    28  	// produce unknown value results rather than actually executing. This is
    29  	// important during a plan phase to avoid generating results that could
    30  	// then differ during apply.
    31  	PureOnly bool
    32  
    33  	funcs     map[string]function.Function
    34  	funcsLock sync.Mutex
    35  
    36  	// activeExperiments is an optional set of experiments that should be
    37  	// considered as active in the module that this scope will be used for.
    38  	// Callers can populate it by calling the SetActiveExperiments method.
    39  	activeExperiments experiments.Set
    40  
    41  	// ConsoleMode can be set to true to request any console-only functions are
    42  	// included in this scope.
    43  	ConsoleMode bool
    44  }
    45  
    46  // SetActiveExperiments allows a caller to declare that a set of experiments
    47  // is active for the module that the receiving Scope belongs to, which might
    48  // then cause the scope to activate some additional experimental behaviors.
    49  func (s *Scope) SetActiveExperiments(active experiments.Set) {
    50  	s.activeExperiments = active
    51  }