core: don't panic if NewResourceConfigShimmed gets a null
When we're working on a create or destroy change it's expected for one of the values to be null. Here we mimick the pre-0.12 behavior of producing just an empty map in that case, which the helper/schema code (now the only caller of this shim) then ignores completely.
This commit is contained in:
parent
6365b9ec7f
commit
1cc9d00da6
|
@ -8,15 +8,14 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
|
||||
"github.com/hashicorp/terraform/configs/configschema"
|
||||
"github.com/hashicorp/terraform/config/hcl2shim"
|
||||
|
||||
"github.com/hashicorp/terraform/config"
|
||||
"github.com/mitchellh/copystructure"
|
||||
"github.com/mitchellh/reflectwalk"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
"github.com/hashicorp/terraform/config"
|
||||
"github.com/hashicorp/terraform/config/hcl2shim"
|
||||
"github.com/hashicorp/terraform/configs/configschema"
|
||||
)
|
||||
|
||||
// ResourceProvisionerConfig is used to pair a provisioner
|
||||
|
@ -247,15 +246,19 @@ func NewResourceConfigShimmed(val cty.Value, schema *configschema.Block) *Resour
|
|||
ret := &ResourceConfig{}
|
||||
|
||||
legacyVal := hcl2shim.ConfigValueFromHCL2(val)
|
||||
ret.Config = legacyVal.(map[string]interface{}) // guaranteed compatible because we require an object type
|
||||
ret.Raw = ret.Config
|
||||
if legacyVal != nil {
|
||||
ret.Config = legacyVal.(map[string]interface{}) // guaranteed compatible because we require an object type
|
||||
|
||||
// Now we need to walk through our structure and find any unknown values,
|
||||
// producing the separate list ComputedKeys to represent these. We use the
|
||||
// schema here so that we can preserve the expected invariant
|
||||
// that an attribute is always either wholly known or wholly unknown, while
|
||||
// a child block can be partially unknown.
|
||||
ret.ComputedKeys = newResourceConfigShimmedComputedKeys(val, schema, "")
|
||||
// Now we need to walk through our structure and find any unknown values,
|
||||
// producing the separate list ComputedKeys to represent these. We use the
|
||||
// schema here so that we can preserve the expected invariant
|
||||
// that an attribute is always either wholly known or wholly unknown, while
|
||||
// a child block can be partially unknown.
|
||||
ret.ComputedKeys = newResourceConfigShimmedComputedKeys(val, schema, "")
|
||||
} else {
|
||||
ret.Config = make(map[string]interface{})
|
||||
}
|
||||
ret.Raw = ret.Config
|
||||
|
||||
return ret
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue