terraform: support both raw and clean config

This commit is contained in:
Mitchell Hashimoto 2014-06-20 12:07:18 -07:00
parent 7fa9bedefd
commit 2fd129ddc4
3 changed files with 17 additions and 5 deletions

View File

@ -58,6 +58,7 @@ type ResourceProvider interface {
type ResourceConfig struct {
ComputedKeys []string
Raw map[string]interface{}
Config map[string]interface{}
}
// ResourceType is a type of resource that a resource provider can manage.
@ -74,6 +75,7 @@ func NewResourceConfig(c *config.RawConfig) *ResourceConfig {
return &ResourceConfig{
ComputedKeys: c.UnknownKeys(),
Raw: c.Raw,
Config: c.Config(),
}
}

View File

@ -278,11 +278,8 @@ func (t *Terraform) genericWalkFn(
// Call the callack
newVars, err := cb(&Resource{
Id: r.Id(),
Config: &ResourceConfig{
ComputedKeys: r.RawConfig.UnknownKeys(),
Raw: r.RawConfig.Config(),
},
Id: r.Id(),
Config: NewResourceConfig(r.RawConfig),
Diff: rd,
Provider: p.Provider,
State: rs,

View File

@ -371,6 +371,19 @@ func testProviderFunc(n string, rs []string) ResourceProviderFactory {
continue
}
// If this key is not computed, then look it up in the
// cleaned config.
found := false
for _, ck := range c.ComputedKeys {
if ck == k {
found = true
break
}
}
if !found {
v = c.Config[k]
}
attrDiff := &ResourceAttrDiff{
Old: "",
New: v.(string),