only unmark deep once for ValidateDeep

pull/38120/head
Daniel Schmidt 4 weeks ago
parent 76747e174c
commit c7bc22ed79

@ -50,8 +50,7 @@ func (d *Deprecations) Validate(value cty.Value, module addrs.Module, rng *hcl.R
// ValidateDeep does the same as Validate but checks deeply nested deprecation marks as well.
func (d *Deprecations) ValidateDeep(value cty.Value, module addrs.Module, rng *hcl.Range) (cty.Value, tfdiags.Diagnostics) {
deprecationMarks := marks.GetDeprecationMarksDeep(value)
notDeprecatedValue := marks.RemoveDeprecationMarksDeep(value)
notDeprecatedValue, deprecationMarks := marks.GetDeprecationMarksDeep(value)
return notDeprecatedValue, d.deprecationMarksToDiagnostics(deprecationMarks, module, rng)
}

@ -70,9 +70,9 @@ func GetDeprecationMarks(val cty.Value) []DeprecationMark {
// GetDeprecationMarksDeep returns all deprecation marks present on the given
// cty.Value or any nested values.
func GetDeprecationMarksDeep(val cty.Value) []DeprecationMark {
_, marks := val.UnmarkDeep()
return FilterDeprecationMarks(marks)
func GetDeprecationMarksDeep(val cty.Value) (cty.Value, []DeprecationMark) {
unmarked, marks := val.UnmarkDeep()
return unmarked, FilterDeprecationMarks(marks)
}
// RemoveDeprecationMarks returns a copy of the given cty.Value with all

Loading…
Cancel
Save