helper/resource: add UpdateFunc

This commit is contained in:
Mitchell Hashimoto 2014-07-02 17:31:58 -07:00
parent 8625e8c2ac
commit cc9ef7a0d3
3 changed files with 12 additions and 2 deletions

View File

@ -44,8 +44,7 @@ func (m *Map) Apply(
if s.ID == "" { if s.ID == "" {
return r.Create(s, d, meta) return r.Create(s, d, meta)
} else { } else {
panic("update no implemented yet") return r.Update(s, d, meta)
//return r.Update(s, d, meta)
} }
} }

View File

@ -0,0 +1 @@
package resource

View File

@ -9,6 +9,7 @@ type Resource struct {
Destroy DestroyFunc Destroy DestroyFunc
Diff DiffFunc Diff DiffFunc
Refresh RefreshFunc Refresh RefreshFunc
Update UpdateFunc
} }
// CreateFunc is a function that creates a resource that didn't previously // CreateFunc is a function that creates a resource that didn't previously
@ -35,3 +36,12 @@ type DiffFunc func(
type RefreshFunc func( type RefreshFunc func(
*terraform.ResourceState, *terraform.ResourceState,
interface{}) (*terraform.ResourceState, error) interface{}) (*terraform.ResourceState, error)
// UpdateFunc is a function that is called to update a resource that
// previously existed. The difference between this and CreateFunc is that
// the diff is guaranteed to only contain attributes that don't require
// a new resource.
type UpdateFunc func(
*terraform.ResourceState,
*terraform.ResourceDiff,
interface{}) (*terraform.ResourceState, error)