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 {
|
type ResourceConfig struct {
|
||||||
ComputedKeys []string
|
ComputedKeys []string
|
||||||
Raw map[string]interface{}
|
Raw map[string]interface{}
|
||||||
|
Config map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResourceType is a type of resource that a resource provider can manage.
|
// ResourceType is a type of resource that a resource provider can manage.
|
||||||
|
@ -74,6 +75,7 @@ func NewResourceConfig(c *config.RawConfig) *ResourceConfig {
|
||||||
return &ResourceConfig{
|
return &ResourceConfig{
|
||||||
ComputedKeys: c.UnknownKeys(),
|
ComputedKeys: c.UnknownKeys(),
|
||||||
Raw: c.Raw,
|
Raw: c.Raw,
|
||||||
|
Config: c.Config(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,11 +278,8 @@ func (t *Terraform) genericWalkFn(
|
||||||
|
|
||||||
// Call the callack
|
// Call the callack
|
||||||
newVars, err := cb(&Resource{
|
newVars, err := cb(&Resource{
|
||||||
Id: r.Id(),
|
Id: r.Id(),
|
||||||
Config: &ResourceConfig{
|
Config: NewResourceConfig(r.RawConfig),
|
||||||
ComputedKeys: r.RawConfig.UnknownKeys(),
|
|
||||||
Raw: r.RawConfig.Config(),
|
|
||||||
},
|
|
||||||
Diff: rd,
|
Diff: rd,
|
||||||
Provider: p.Provider,
|
Provider: p.Provider,
|
||||||
State: rs,
|
State: rs,
|
||||||
|
|
|
@ -371,6 +371,19 @@ func testProviderFunc(n string, rs []string) ResourceProviderFactory {
|
||||||
continue
|
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{
|
attrDiff := &ResourceAttrDiff{
|
||||||
Old: "",
|
Old: "",
|
||||||
New: v.(string),
|
New: v.(string),
|
||||||
|
|
Loading…
Reference in New Issue