mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-02-26 08:02:46 -05:00
command+backend/local: -refresh-only and drift detection
This is a light revamp of our plan output to make use of Terraform core's new ability to report both the previous run state and the refreshed state, allowing us to explicitly report changes made outside of Terraform. Because whether a plan has "changes" or not is no longer such a straightforward matter, this now merges views.Operation.Plan with views.Operation.PlanNoChanges to produce a single function that knows how to report all of the various permutations. This was also an opportunity to fill some holes in our previous logic which caused it to produce some confusing messages, including a new tailored message for when "terraform destroy" detects that nothing needs to be destroyed. This also allows users to request the refresh-only planning mode using a new -refresh-only command line option. In that case, Terraform _only_ performs drift detection, and so applying a refresh-only plan only involves writing a new state snapshot, without changing any real infrastructure objects.
This commit is contained in:
@@ -235,12 +235,14 @@ func ResourceInstanceDrift(
|
||||
}
|
||||
if after != nil && after.Current != nil {
|
||||
newObj, err = after.Current.Decode(ty)
|
||||
// We shouldn't encounter errors here because Terraform Core should've
|
||||
// made sure that the prior state object conforms to the current
|
||||
// schema by having the provider upgrade it, even if we skipped
|
||||
// refreshing on this run, but we'll be robust here in case there are
|
||||
// some edges we didn't find yet.
|
||||
return fmt.Sprintf(" # %s refreshed state doesn't conform to current schema; this is a Terraform bug\n # %s\n", addr, err)
|
||||
if err != nil {
|
||||
// We shouldn't encounter errors here because Terraform Core should've
|
||||
// made sure that the prior state object conforms to the current
|
||||
// schema by having the provider upgrade it, even if we skipped
|
||||
// refreshing on this run, but we'll be robust here in case there are
|
||||
// some edges we didn't find yet.
|
||||
return fmt.Sprintf(" # %s refreshed state doesn't conform to current schema; this is a Terraform bug\n # %s\n", addr, err)
|
||||
}
|
||||
}
|
||||
|
||||
oldVal := oldObj.Value
|
||||
|
||||
Reference in New Issue
Block a user