terraform: pass through the unknown keys
This commit is contained in:
parent
f15746f692
commit
a256f27b24
|
@ -32,7 +32,8 @@ 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 {
|
||||
Raw map[string]interface{}
|
||||
ComputedKeys []string
|
||||
Raw map[string]interface{}
|
||||
}
|
||||
|
||||
// ResourceType is a type of resource that a resource provider can manage.
|
||||
|
|
|
@ -151,7 +151,8 @@ func (t *Terraform) diffWalkFn(
|
|||
l.RUnlock()
|
||||
|
||||
diff, err := p.Provider.Diff(rs, &ResourceConfig{
|
||||
Raw: r.RawConfig.Config(),
|
||||
ComputedKeys: r.RawConfig.UnknownKeys(),
|
||||
Raw: r.RawConfig.Config(),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -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