terraform: fix more cases where nil access can happen
This commit is contained in:
parent
be82499f3c
commit
3e4bdb5584
|
@ -271,6 +271,11 @@ func (c *Context) Validate() ([]string, []error) {
|
||||||
// the variables. This dynamically discovers the attributes instead of
|
// the variables. This dynamically discovers the attributes instead of
|
||||||
// using a static map[string]string that the genericWalkFn uses.
|
// using a static map[string]string that the genericWalkFn uses.
|
||||||
func (c *Context) computeVars(raw *config.RawConfig) error {
|
func (c *Context) computeVars(raw *config.RawConfig) error {
|
||||||
|
// If there isn't a raw configuration, don't do anything
|
||||||
|
if raw == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// If there are on variables, then we're done
|
// If there are on variables, then we're done
|
||||||
if len(raw.Variables) == 0 {
|
if len(raw.Variables) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
@ -735,14 +740,14 @@ func (c *Context) genericWalkFn(cb genericWalkFunc) depgraph.WalkFunc {
|
||||||
return nil
|
return nil
|
||||||
case *GraphNodeResourceProvider:
|
case *GraphNodeResourceProvider:
|
||||||
// Interpolate in the variables and configure all the providers
|
// Interpolate in the variables and configure all the providers
|
||||||
var rc *ResourceConfig
|
var raw *config.RawConfig
|
||||||
if m.Config != nil {
|
if m.Config != nil {
|
||||||
if err := c.computeVars(m.Config.RawConfig); err != nil {
|
raw = m.Config.RawConfig
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
rc = NewResourceConfig(m.Config.RawConfig)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc := NewResourceConfig(raw)
|
||||||
|
rc.interpolate(c)
|
||||||
|
|
||||||
for k, p := range m.Providers {
|
for k, p := range m.Providers {
|
||||||
log.Printf("[INFO] Configuring provider: %s", k)
|
log.Printf("[INFO] Configuring provider: %s", k)
|
||||||
err := p.Configure(rc)
|
err := p.Configure(rc)
|
||||||
|
|
Loading…
Reference in New Issue