only unmark deep once for ValidateDeep

This commit is contained in:
Daniel Schmidt 2026-01-21 16:42:04 +01:00
parent 76747e174c
commit c7bc22ed79
2 changed files with 4 additions and 5 deletions

View file

@ -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)
}

View file

@ -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