Marshal plan#relevant_attributes in deterministic order (#327)

Signed-off-by: Marcin Wyszynski <marcin.pixie@gmail.com>
This commit is contained in:
Marcin Wyszynski 2023-09-07 13:36:16 +02:00 committed by GitHub
parent c22a387167
commit 992b5d604a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View File

@ -682,6 +682,13 @@ func (p *Plan) marshalRelevantAttrs(plan *plans.Plan) error {
p.RelevantAttributes = append(p.RelevantAttributes, ResourceAttr{addr, path})
}
// We sort the relevant attributes by resource address to make the output
// deterministic. Our own equivalence tests rely on it.
sort.Slice(p.RelevantAttributes, func(i, j int) bool {
return p.RelevantAttributes[i].Resource < p.RelevantAttributes[j].Resource
})
return nil
}

View File

@ -203,17 +203,17 @@
}
},
"relevant_attributes": [
{
"attribute": [
"id"
],
"resource": "module.create.random_integer.random"
},
{
"attribute": [
"string"
],
"resource": "data.tfcoremock_simple_resource.read"
},
{
"attribute": [
"id"
],
"resource": "module.create.random_integer.random"
}
],
"resource_changes": [