terraform: validate should use the full config

This commit is contained in:
Mitchell Hashimoto 2014-09-29 12:04:14 -07:00
parent af548c9b53
commit 99d0e52ead
1 changed files with 8 additions and 36 deletions

View File

@ -1021,45 +1021,17 @@ func (c *walkContext) validateWalkFn() depgraph.WalkFunc {
case *GraphNodeResourceProvider: case *GraphNodeResourceProvider:
sharedProvider := rn.Provider sharedProvider := rn.Provider
var raw *config.RawConfig // Check if we have an override
if sharedProvider.Config != nil { cs, ok := c.Context.providerConfig[rn.ID]
raw = sharedProvider.Config.RawConfig if !ok {
cs = make(map[string]map[string]interface{})
} }
// If we have a parent, then merge in the parent configurations
// properly so we "inherit" the configurations.
if sharedProvider.Parent != nil {
var rawMap map[string]interface{}
if raw != nil {
rawMap = raw.Raw
}
parent := sharedProvider.Parent
for parent != nil {
if parent.Config != nil {
if rawMap == nil {
rawMap = parent.Config.RawConfig.Raw
}
for k, v := range parent.Config.RawConfig.Raw {
rawMap[k] = v
}
}
parent = parent.Parent
}
// Update our configuration to be the merged result
var err error
raw, err = config.NewRawConfig(rawMap)
if err != nil {
return fmt.Errorf("Error merging configurations: %s", err)
}
}
rc := NewResourceConfig(raw)
for k, p := range sharedProvider.Providers { for k, p := range sharedProvider.Providers {
// Merge the configurations to get what we use to configure with
rc := sharedProvider.MergeConfig(false, cs[k])
rc.interpolate(c)
log.Printf("[INFO] Validating provider: %s", k) log.Printf("[INFO] Validating provider: %s", k)
ws, es := p.Validate(rc) ws, es := p.Validate(rc)
for i, w := range ws { for i, w := range ws {