Skip to content

Commit

Permalink
intentionally ignore error if force = true
Browse files Browse the repository at this point in the history
This resets error to nil in a necessary codepath if/when `force = true`
to intentionally ignore terraform plan diffs.

Signed-off-by: Mike Ball <mikedball@gmail.com>
  • Loading branch information
mdb committed Sep 13, 2023
1 parent cd51021 commit 495d41f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tfmigrate/multi_state_migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ func (m *MultiStateMigrator) plan(ctx context.Context) (fromCurrentState *tfexec
return nil, nil, fmt.Errorf("terraform plan command returns unexpected diffs in %s from_dir: %s", m.fromTf.Dir(), err)
}
log.Printf("[INFO] [migrator@%s] unexpected diffs, ignoring as force option is true: %s", m.fromTf.Dir(), err)
// reset err to nil to intentionally ignore unexpected diffs.
err = nil
} else {
return nil, nil, err
}
Expand All @@ -188,7 +190,6 @@ func (m *MultiStateMigrator) plan(ctx context.Context) (fromCurrentState *tfexec
log.Printf("[ERROR] [migrator@%s] unexpected diffs\n", m.toTf.Dir())
return nil, nil, fmt.Errorf("terraform plan command returns unexpected diffs in %s to_dir: %s", m.toTf.Dir(), err)
}

log.Printf("[INFO] [migrator@%s] unexpected diffs, ignoring as force option is true: %s", m.toTf.Dir(), err)
// reset err to nil to intentionally ignore unexpected diffs.
err = nil
Expand Down

0 comments on commit 495d41f

Please sign in to comment.