From 87c3423fd4526d44d741bc31d4adc968802a5930 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Tue, 8 Jul 2014 14:45:45 -0700 Subject: [PATCH] terrform: Thread provisioner factory through Context --- terraform/context.go | 73 ++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/terraform/context.go b/terraform/context.go index 97a86624c..308ea9127 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -22,12 +22,13 @@ type genericWalkFunc func(*Resource) error // // Additionally, a context can be created from a Plan using Plan.Context. type Context struct { - config *config.Config - diff *Diff - hooks []Hook - state *State - providers map[string]ResourceProviderFactory - variables map[string]string + config *config.Config + diff *Diff + hooks []Hook + state *State + providers map[string]ResourceProviderFactory + provisioners map[string]ResourceProvisionerFactory + variables map[string]string l sync.Mutex // Lock acquired during any task parCh chan struct{} // Semaphore used to limit parallelism @@ -39,13 +40,14 @@ type Context struct { // ContextOpts are the user-creatable configuration structure to create // a context with NewContext. type ContextOpts struct { - Config *config.Config - Diff *Diff - Hooks []Hook - Parallelism int - State *State - Providers map[string]ResourceProviderFactory - Variables map[string]string + Config *config.Config + Diff *Diff + Hooks []Hook + Parallelism int + State *State + Providers map[string]ResourceProviderFactory + Provisioners map[string]ResourceProvisionerFactory + Variables map[string]string } // NewContext creates a new context. @@ -70,12 +72,13 @@ func NewContext(opts *ContextOpts) *Context { parCh := make(chan struct{}, par) return &Context{ - config: opts.Config, - diff: opts.Diff, - hooks: hooks, - state: opts.State, - providers: opts.Providers, - variables: opts.Variables, + config: opts.Config, + diff: opts.Diff, + hooks: hooks, + state: opts.State, + providers: opts.Providers, + provisioners: opts.Provisioners, + variables: opts.Variables, parCh: parCh, sh: sh, @@ -92,10 +95,11 @@ func (c *Context) Apply() (*State, error) { defer c.releaseRun(v) g, err := Graph(&GraphOpts{ - Config: c.config, - Diff: c.diff, - Providers: c.providers, - State: c.state, + Config: c.config, + Diff: c.diff, + Providers: c.providers, + Provisioners: c.provisioners, + State: c.state, }) if err != nil { return nil, err @@ -135,9 +139,10 @@ func (c *Context) Plan(opts *PlanOpts) (*Plan, error) { defer c.releaseRun(v) g, err := Graph(&GraphOpts{ - Config: c.config, - Providers: c.providers, - State: c.state, + Config: c.config, + Providers: c.providers, + Provisioners: c.provisioners, + State: c.state, }) if err != nil { return nil, err @@ -188,9 +193,10 @@ func (c *Context) Refresh() (*State, error) { defer c.releaseRun(v) g, err := Graph(&GraphOpts{ - Config: c.config, - Providers: c.providers, - State: c.state, + Config: c.config, + Providers: c.providers, + Provisioners: c.provisioners, + State: c.state, }) if err != nil { return c.state, err @@ -384,10 +390,11 @@ func (c *Context) computeResourceMultiVariable( func (c *Context) graph() (*depgraph.Graph, error) { return Graph(&GraphOpts{ - Config: c.config, - Diff: c.diff, - Providers: c.providers, - State: c.state, + Config: c.config, + Diff: c.diff, + Providers: c.providers, + Provisioners: c.provisioners, + State: c.state, }) }