jsonplan: deterministic relevant attribute order (#36076)

* jsonplan: deterministic relevant attribute order

* simplify sort function
pull/36089/head
Liam Cervante 1 year ago committed by GitHub
parent b4a634ced8
commit 36d7e8706f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -758,6 +758,15 @@ func (p *plan) marshalRelevantAttrs(plan *plans.Plan) error {
p.RelevantAttributes = append(p.RelevantAttributes, ResourceAttr{addr, path})
}
// we want our outputs to be deterministic, so we'll sort the attributes
// here. The order of the attributes is not important, as long as it is
// stable.
sort.SliceStable(plan.RelevantAttributes, func(i, j int) bool {
return strings.Compare(fmt.Sprintf("%#v", plan.RelevantAttributes[i]), fmt.Sprintf("%#v", plan.RelevantAttributes[j])) < 0
})
return nil
}

Loading…
Cancel
Save