github.com/trawler/terraform@v0.10.8-0.20171106022149-4b1c7a1d9b48/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 type and 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(typ string, name 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 44 // ProviderInput and SetProviderInput are used to configure providers 45 // from user input. 46 ProviderInput(string) map[string]interface{} 47 SetProviderInput(string, map[string]interface{}) 48 49 // InitProvisioner initializes the provisioner with the given name and 50 // returns the implementation of the resource provisioner or an error. 51 // 52 // It is an error to initialize the same provisioner more than once. 53 InitProvisioner(string) (ResourceProvisioner, error) 54 55 // Provisioner gets the provisioner instance with the given name (already 56 // initialized) or returns nil if the provisioner isn't initialized. 57 Provisioner(string) ResourceProvisioner 58 59 // CloseProvisioner closes provisioner connections that aren't needed 60 // anymore. 61 CloseProvisioner(string) error 62 63 // Interpolate takes the given raw configuration and completes 64 // the interpolations, returning the processed ResourceConfig. 65 // 66 // The resource argument is optional. If given, it is the resource 67 // that is currently being acted upon. 68 Interpolate(*config.RawConfig, *Resource) (*ResourceConfig, error) 69 70 // InterpolateProvider takes a ProviderConfig and interpolates it with the 71 // stored interpolation scope. Since provider configurations can be 72 // inherited, the interpolation scope may be different from the current 73 // context path. Interplation is otherwise executed the same as in the 74 // Interpolation method. 75 InterpolateProvider(*config.ProviderConfig, *Resource) (*ResourceConfig, error) 76 77 // SetVariables sets the variables for the module within 78 // this context with the name n. This function call is additive: 79 // the second parameter is merged with any previous call. 80 SetVariables(string, map[string]interface{}) 81 82 // Diff returns the global diff as well as the lock that should 83 // be used to modify that diff. 84 Diff() (*Diff, *sync.RWMutex) 85 86 // State returns the global state as well as the lock that should 87 // be used to modify that state. 88 State() (*State, *sync.RWMutex) 89 }