mirror of https://github.com/coder/coder.git
fix(provisioner/terraform): ensure ordering rich parameters produces no nil values (#7824)
This commit is contained in:
parent
5a3d6b589a
commit
1ab2450250
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue