fix(provisioner/terraform): ensure ordering rich parameters produces no nil values (#7824)

This commit is contained in:
Colin Adler 2023-06-05 11:26:04 -05:00 committed by GitHub
parent 5a3d6b589a
commit 1ab2450250
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -694,5 +694,21 @@ func orderedRichParametersResources(tfResourcesRichParameters []*tfjson.StateRes
}
}
}
// There's an edge case possible for us to have a parameter name that isn't
// present in the state, since the ordered names come statically from
// parsing the Terraform file. We need to filter out the nil values if there
// are any present.
if len(tfResourcesRichParameters) != len(orderedNames) {
nonNil := make([]*tfjson.StateResource, 0, len(ordered))
for _, resource := range ordered {
if resource != nil {
nonNil = append(nonNil, resource)
}
}
ordered = nonNil
}
return ordered
}