mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 00:41:27 -06:00
command: apply uses the new plan structure
This commit is contained in:
parent
3aab0cd21b
commit
84cf644a30
@ -95,13 +95,13 @@ func (c *ApplyCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
_, err = tf.Plan(state)
|
||||
plan, err := tf.Plan(state)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error running plan: %s", err))
|
||||
return 1
|
||||
}
|
||||
|
||||
state, err = tf.Apply(state, nil)
|
||||
state, err = tf.Apply(plan)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error applying plan: %s", err))
|
||||
return 1
|
||||
|
@ -25,6 +25,10 @@ func testTFConfig(p terraform.ResourceProvider) *terraform.Config {
|
||||
|
||||
func testProvider() *terraform.MockResourceProvider {
|
||||
p := new(terraform.MockResourceProvider)
|
||||
p.RefreshFn = func(
|
||||
s *terraform.ResourceState) (*terraform.ResourceState, error) {
|
||||
return s, nil
|
||||
}
|
||||
p.ResourcesReturn = []terraform.ResourceType{
|
||||
terraform.ResourceType{
|
||||
Name: "test_instance",
|
||||
|
@ -201,8 +201,10 @@ func (t *Terraform) planWalkFn(
|
||||
if !diff.Empty() {
|
||||
rs = r.State.MergeDiff(diff)
|
||||
}
|
||||
for ak, av := range rs.Attributes {
|
||||
vars[fmt.Sprintf("%s.%s", r.Id, ak)] = av
|
||||
if rs != nil {
|
||||
for ak, av := range rs.Attributes {
|
||||
vars[fmt.Sprintf("%s.%s", r.Id, ak)] = av
|
||||
}
|
||||
}
|
||||
|
||||
return vars, nil
|
||||
|
Loading…
Reference in New Issue
Block a user