core: Use hcl.ApplyPath for ignore_changes and "requires replace"
We were previously using cty.Path.Apply, which serves a similar purpose but implements the more restrictive traversal behaviors down at the cty layer. hcl.ApplyPath uses the same rules as HCL expressions and so ensures consistent behavior with normal user expressions. cty.Path.Apply also previously had a crashing bug (discussed in #20084) that was causing a panic here. That has now been fixed in cty, but since we're no longer using it here that's a moot point. The HCL traversing implementation has been fuzz-tested and unit tested a lot more thoroughly so should not run into the same crashers we saw with cty before.
This commit is contained in:
parent
c8d34b55ee
commit
a8f97a0805
|
@ -240,8 +240,8 @@ func (n *EvalDiff) Eval(ctx EvalContext) (interface{}, error) {
|
|||
// when we use this value below, if the provider misbehaves.)
|
||||
continue
|
||||
}
|
||||
plannedChangedVal, err := path.Apply(plannedNewVal)
|
||||
if err != nil {
|
||||
plannedChangedVal, pathDiags := hcl.ApplyPath(plannedNewVal, path, nil)
|
||||
if pathDiags.HasErrors() {
|
||||
// This always indicates a provider bug, since RequiresReplace
|
||||
// should always refer only to whole attributes (and not into
|
||||
// attribute values themselves) and these should always be
|
||||
|
@ -492,9 +492,9 @@ func processIgnoreChangesIndividual(prior, proposed cty.Value, ignoreChanges []h
|
|||
// If we're able to follow the same path through the prior value,
|
||||
// we'll take the value there instead, effectively undoing the
|
||||
// change that was planned.
|
||||
priorV, err := path.Apply(prior)
|
||||
if err != nil {
|
||||
// We just ignore the error and move on here, since we assume it's
|
||||
priorV, diags := hcl.ApplyPath(prior, path, nil)
|
||||
if diags.HasErrors() {
|
||||
// We just ignore the errors and move on here, since we assume it's
|
||||
// just because the prior value was a slightly-different shape.
|
||||
// It could potentially also be that the traversal doesn't match
|
||||
// the schema, but we should've caught that during the validate
|
||||
|
|
Loading…
Reference in New Issue