remove unused actionforchange (#32759)

This commit is contained in:
kmoe 2023-03-01 14:15:26 +00:00 committed by GitHub
parent 93f9cff99f
commit 76b34e891c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,40 +0,0 @@
package objchange
import (
"github.com/zclconf/go-cty/cty"
"github.com/hashicorp/terraform/internal/plans"
)
// ActionForChange determines which plans.Action value best describes a
// change from the value given in before to the value given in after.
//
// Because it has no context aside from the values, it can only return the
// basic actions NoOp, Create, Update, and Delete. Other codepaths with
// additional information might make this decision differently, such as by
// using the Replace action instead of the Update action where that makes
// sense.
//
// If the after value is unknown then the action can't be properly decided, and
// so ActionForChange will conservatively return either Create or Update
// depending on whether the before value is null. The before value must always
// be fully known; ActionForChange will panic if it contains any unknown values.
func ActionForChange(before, after cty.Value) plans.Action {
switch {
case !after.IsKnown():
if before.IsNull() {
return plans.Create
}
return plans.Update
case after.IsNull() && before.IsNull():
return plans.NoOp
case after.IsNull() && !before.IsNull():
return plans.Delete
case before.IsNull() && !after.IsNull():
return plans.Create
case after.RawEquals(before):
return plans.NoOp
default:
return plans.Update
}
}