github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/terraform/eval_context.go (about)

     1  package terraform
     2  
     3  import (
     4  	"sync"
     5  
     6  	"github.com/hashicorp/terraform/config"
     7  )
     8  
     9  // EvalContext is the interface that is given to eval nodes to execute.
    10  type EvalContext interface {
    11  	// Stopped returns a channel that is closed when evaluation is stopped
    12  	// via Terraform.Context.Stop()
    13  	Stopped() <-chan struct{}
    14  
    15  	// Path is the current module path.
    16  	Path() []string
    17  
    18  	// Hook is used to call hook methods. The callback is called for each
    19  	// hook and should return the hook action to take and the error.
    20  	Hook(func(Hook) (HookAction, error)) error
    21  
    22  	// Input is the UIInput object for interacting with the UI.
    23  	Input() UIInput
    24  
    25  	// InitProvider initializes the provider with the given name and
    26  	// returns the implementation of the resource provider or an error.
    27  	//
    28  	// It is an error to initialize the same provider more than once.
    29  	InitProvider(string) (ResourceProvider, error)
    30  
    31  	// Provider gets the provider instance with the given name (already
    32  	// initialized) or returns nil if the provider isn't initialized.
    33  	Provider(string) ResourceProvider
    34  
    35  	// CloseProvider closes provider connections that aren't needed anymore.
    36  	CloseProvider(string) error
    37  
    38  	// ConfigureProvider configures the provider with the given
    39  	// configuration. This is a separate context call because this call
    40  	// is used to store the provider configuration for inheritance lookups
    41  	// with ParentProviderConfig().
    42  	ConfigureProvider(string, *ResourceConfig) error
    43  	SetProviderConfig(string, *ResourceConfig) error
    44  	ParentProviderConfig(string) *ResourceConfig
    45  
    46  	// ProviderInput and SetProviderInput are used to configure providers
    47  	// from user input.
    48  	ProviderInput(string) map[string]interface{}
    49  	SetProviderInput(string, map[string]interface{})
    50  
    51  	// InitProvisioner initializes the provisioner with the given name and
    52  	// returns the implementation of the resource provisioner or an error.
    53  	//
    54  	// It is an error to initialize the same provisioner more than once.
    55  	InitProvisioner(string) (ResourceProvisioner, error)
    56  
    57  	// Provisioner gets the provisioner instance with the given name (already
    58  	// initialized) or returns nil if the provisioner isn't initialized.
    59  	Provisioner(string) ResourceProvisioner
    60  
    61  	// CloseProvisioner closes provisioner connections that aren't needed
    62  	// anymore.
    63  	CloseProvisioner(string) error
    64  
    65  	// Interpolate takes the given raw configuration and completes
    66  	// the interpolations, returning the processed ResourceConfig.
    67  	//
    68  	// The resource argument is optional. If given, it is the resource
    69  	// that is currently being acted upon.
    70  	Interpolate(*config.RawConfig, *Resource) (*ResourceConfig, error)
    71  
    72  	// SetVariables sets the variables for the module within
    73  	// this context with the name n. This function call is additive:
    74  	// the second parameter is merged with any previous call.
    75  	SetVariables(string, map[string]interface{})
    76  
    77  	// Diff returns the global diff as well as the lock that should
    78  	// be used to modify that diff.
    79  	Diff() (*Diff, *sync.RWMutex)
    80  
    81  	// State returns the global state as well as the lock that should
    82  	// be used to modify that state.
    83  	State() (*State, *sync.RWMutex)
    84  }