mirror of
https://github.com/hashicorp/terraform.git
synced 2026-06-09 00:42:48 -04:00
jsonplan: deterministic relevant attribute order (#36076)
* jsonplan: deterministic relevant attribute order * simplify sort function
This commit is contained in:
parent
b4a634ced8
commit
36d7e8706f
1 changed files with 9 additions and 0 deletions
|
|
@ -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…
Reference in a new issue