GetDeprecationMarks should return other value marks in value

This commit is contained in:
Daniel Schmidt 2026-01-23 12:02:14 +01:00
parent 9d359b02c4
commit ce400c93df

View file

@ -51,21 +51,25 @@ func Contains(val cty.Value, mark interface{}) bool {
// FilterDeprecationMarks returns all deprecation marks present in the given
// cty.ValueMarks.
func FilterDeprecationMarks(marks cty.ValueMarks) []DeprecationMark {
func FilterDeprecationMarks(marks cty.ValueMarks) (cty.ValueMarks, []DeprecationMark) {
other := cty.ValueMarks{}
depMarks := []DeprecationMark{}
for mark := range marks {
if d, ok := mark.(DeprecationMark); ok {
depMarks = append(depMarks, d)
} else {
other[mark] = struct{}{}
}
}
return depMarks
return other, depMarks
}
// GetDeprecationMarks returns all deprecation marks present on the given
// cty.Value.
func GetDeprecationMarks(val cty.Value) (cty.Value, []DeprecationMark) {
unmarked, marks := val.Unmark()
return unmarked, FilterDeprecationMarks(marks)
other, depMarks := FilterDeprecationMarks(marks)
return unmarked.WithMarks(other), depMarks
}
// RemoveDeprecationMarks returns a copy of the given cty.Value with all