terraform: pass through the unknown keys

This commit is contained in:
Mitchell Hashimoto 2014-06-12 18:11:21 -07:00
parent f15746f692
commit a256f27b24
3 changed files with 17 additions and 7 deletions

View File

@ -32,7 +32,8 @@ type ResourceProvider interface {
// done instead of a raw `map[string]interface{}` type so that rich // done instead of a raw `map[string]interface{}` type so that rich
// methods can be added to it to make dealing with it easier. // methods can be added to it to make dealing with it easier.
type ResourceConfig struct { 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. // ResourceType is a type of resource that a resource provider can manage.

View File

@ -151,7 +151,8 @@ func (t *Terraform) diffWalkFn(
l.RUnlock() l.RUnlock()
diff, err := p.Provider.Diff(rs, &ResourceConfig{ diff, err := p.Provider.Diff(rs, &ResourceConfig{
Raw: r.RawConfig.Config(), ComputedKeys: r.RawConfig.UnknownKeys(),
Raw: r.RawConfig.Config(),
}) })
if err != nil { if err != nil {
return err return err
@ -181,18 +182,19 @@ func (t *Terraform) diffWalkFn(
func (t *terraformProvider) init(vars map[string]string) (err error) { func (t *terraformProvider) init(vars map[string]string) (err error) {
t.Once.Do(func() { t.Once.Do(func() {
var c map[string]interface{} var rc *ResourceConfig
if t.Config != nil { if t.Config != nil {
if err := t.Config.RawConfig.Interpolate(vars); err != nil { if err := t.Config.RawConfig.Interpolate(vars); err != nil {
panic(err) panic(err)
} }
c = t.Config.RawConfig.Config() rc = &ResourceConfig{
ComputedKeys: t.Config.RawConfig.UnknownKeys(),
Raw: t.Config.RawConfig.Config(),
}
} }
err = t.Provider.Configure(&ResourceConfig{ err = t.Provider.Configure(rc)
Raw: c,
})
}) })
return return

View File

@ -306,6 +306,13 @@ func testProviderFunc(n string, rs []string) ResourceProviderFactory {
diff.Attributes[k] = attrDiff diff.Attributes[k] = attrDiff
} }
for _, k := range c.ComputedKeys {
diff.Attributes[k] = &ResourceAttrDiff{
Old: "",
NewComputed: true,
}
}
return &diff, nil return &diff, nil
} }