core: NewResourceConfigShimmed not to crash without schema

Although there isn't really a good reason why there should be no schema
in practice, it's better for us not to crash right now while we're still
updating all of the callers (mostly tests) to make schema available.
This commit is contained in:
Martin Atkins 2018-05-24 18:40:20 -07:00
parent c6b2799ee9
commit 153021dd08

View File

@ -2,6 +2,7 @@ package terraform
import (
"fmt"
"log"
"reflect"
"sort"
"strconv"
@ -256,6 +257,11 @@ func newResourceConfigShimmedComputedKeys(obj cty.Value, schema *configschema.Bl
var ret []string
ty := obj.Type()
if schema == nil {
log.Printf("[WARN] NewResourceConfigShimmed: can't identify computed keys because no schema is available")
return nil
}
for attrName := range schema.Attributes {
if !ty.HasAttribute(attrName) {
// Should never happen, but we'll tolerate it anyway