terraform: support both raw and clean config
This commit is contained in:
parent
7fa9bedefd
commit
2fd129ddc4
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue