terraform: pass through the unknown keys
This commit is contained in:
parent
f15746f692
commit
a256f27b24
|
@ -32,6 +32,7 @@ type ResourceProvider interface {
|
|||
// done instead of a raw `map[string]interface{}` type so that rich
|
||||
// methods can be added to it to make dealing with it easier.
|
||||
type ResourceConfig struct {
|
||||
ComputedKeys []string
|
||||
Raw map[string]interface{}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,6 +151,7 @@ func (t *Terraform) diffWalkFn(
|
|||
l.RUnlock()
|
||||
|
||||
diff, err := p.Provider.Diff(rs, &ResourceConfig{
|
||||
ComputedKeys: r.RawConfig.UnknownKeys(),
|
||||
Raw: r.RawConfig.Config(),
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -181,18 +182,19 @@ func (t *Terraform) diffWalkFn(
|
|||
|
||||
func (t *terraformProvider) init(vars map[string]string) (err error) {
|
||||
t.Once.Do(func() {
|
||||
var c map[string]interface{}
|
||||
var rc *ResourceConfig
|
||||
if t.Config != nil {
|
||||
if err := t.Config.RawConfig.Interpolate(vars); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c = t.Config.RawConfig.Config()
|
||||
rc = &ResourceConfig{
|
||||
ComputedKeys: t.Config.RawConfig.UnknownKeys(),
|
||||
Raw: t.Config.RawConfig.Config(),
|
||||
}
|
||||
}
|
||||
|
||||
err = t.Provider.Configure(&ResourceConfig{
|
||||
Raw: c,
|
||||
})
|
||||
err = t.Provider.Configure(rc)
|
||||
})
|
||||
|
||||
return
|
||||
|
|
|
@ -306,6 +306,13 @@ func testProviderFunc(n string, rs []string) ResourceProviderFactory {
|
|||
diff.Attributes[k] = attrDiff
|
||||
}
|
||||
|
||||
for _, k := range c.ComputedKeys {
|
||||
diff.Attributes[k] = &ResourceAttrDiff{
|
||||
Old: "",
|
||||
NewComputed: true,
|
||||
}
|
||||
}
|
||||
|
||||
return &diff, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue