terraform: no longer store the graph on Terraform itself

This commit is contained in:
Mitchell Hashimoto 2014-06-24 10:16:48 -07:00
parent 1df3297601
commit 4084ed9234
1 changed files with 12 additions and 4 deletions

View File

@ -13,7 +13,6 @@ import (
// all resources, a resource tree, a specific resource, etc. // all resources, a resource tree, a specific resource, etc.
type Terraform struct { type Terraform struct {
config *config.Config config *config.Config
graph *depgraph.Graph
mapping map[*config.Resource]*terraformProvider mapping map[*config.Resource]*terraformProvider
variables map[string]string variables map[string]string
} }
@ -97,21 +96,30 @@ func New(c *Config) (*Terraform, error) {
return &Terraform{ return &Terraform{
config: c.Config, config: c.Config,
graph: graph,
mapping: mapping, mapping: mapping,
variables: c.Variables, variables: c.Variables,
}, nil }, nil
} }
func (t *Terraform) Apply(p *Plan) (*State, error) { func (t *Terraform) Apply(p *Plan) (*State, error) {
graph := t.config.Graph()
if err := graph.Validate(); err != nil {
panic(fmt.Sprintf("Graph invalid after prior validation: %s", err))
}
result := new(State) result := new(State)
err := t.graph.Walk(t.applyWalkFn(p, result)) err := graph.Walk(t.applyWalkFn(p, result))
return result, err return result, err
} }
func (t *Terraform) Plan(s *State) (*Plan, error) { func (t *Terraform) Plan(s *State) (*Plan, error) {
graph := t.config.Graph()
if err := graph.Validate(); err != nil {
panic(fmt.Sprintf("Graph invalid after prior validation: %s", err))
}
result := new(Plan) result := new(Plan)
err := t.graph.Walk(t.planWalkFn(s, result)) err := graph.Walk(t.planWalkFn(s, result))
if err != nil { if err != nil {
return nil, err return nil, err
} }