mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 00:41:27 -06:00
terraform: Apply takes a plan
This commit is contained in:
parent
a0cbbab03b
commit
3aab0cd21b
@ -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(
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user