terraform: Apply takes a plan

This commit is contained in:
Mitchell Hashimoto 2014-06-20 12:49:01 -07:00
parent a0cbbab03b
commit 3aab0cd21b
2 changed files with 6 additions and 9 deletions

View File

@ -103,9 +103,9 @@ func New(c *Config) (*Terraform, error) {
}, nil
}
func (t *Terraform) Apply(s *State, d *Diff) (*State, error) {
func (t *Terraform) Apply(p *Plan) (*State, error) {
result := new(State)
err := t.graph.Walk(t.applyWalkFn(s, d, result))
err := t.graph.Walk(t.applyWalkFn(p, result))
if err != nil {
return nil, err
}
@ -128,8 +128,7 @@ func (t *Terraform) Refresh(*State) (*State, error) {
}
func (t *Terraform) applyWalkFn(
state *State,
diff *Diff,
p *Plan,
result *State) depgraph.WalkFunc {
var l sync.Mutex
@ -162,7 +161,7 @@ func (t *Terraform) applyWalkFn(
return vars, nil
}
return t.genericWalkFn(state, diff, cb)
return t.genericWalkFn(p.State, p.Diff, cb)
}
func (t *Terraform) planWalkFn(

View File

@ -203,17 +203,16 @@ func TestNew_variables(t *testing.T) {
}
}
/*
func TestTerraformApply(t *testing.T) {
tf := testTerraform(t, "apply-good")
s := &State{}
d, err := tf.Diff(s)
p, err := tf.Plan(s)
if err != nil {
t.Fatalf("err: %s", err)
}
state, err := tf.Apply(s, d)
state, err := tf.Apply(p)
if err != nil {
t.Fatalf("err: %s", err)
}
@ -228,7 +227,6 @@ func TestTerraformApply(t *testing.T) {
t.Fatalf("bad: \n%s", actual)
}
}
*/
func TestTerraformPlan(t *testing.T) {
tf := testTerraform(t, "plan-good")