From cc9ef7a0d3d124bbde1d70c80097eea5ac418a8b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 2 Jul 2014 17:31:58 -0700 Subject: [PATCH] helper/resource: add UpdateFunc --- helper/resource/map.go | 3 +-- helper/resource/map_test.go | 1 + helper/resource/resource.go | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 helper/resource/map_test.go diff --git a/helper/resource/map.go b/helper/resource/map.go index 301db8b14..523c24b8e 100644 --- a/helper/resource/map.go +++ b/helper/resource/map.go @@ -44,8 +44,7 @@ func (m *Map) Apply( if s.ID == "" { return r.Create(s, d, meta) } else { - panic("update no implemented yet") - //return r.Update(s, d, meta) + return r.Update(s, d, meta) } } diff --git a/helper/resource/map_test.go b/helper/resource/map_test.go new file mode 100644 index 000000000..958e3540f --- /dev/null +++ b/helper/resource/map_test.go @@ -0,0 +1 @@ +package resource diff --git a/helper/resource/resource.go b/helper/resource/resource.go index 3409228d1..0437b34e1 100644 --- a/helper/resource/resource.go +++ b/helper/resource/resource.go @@ -9,6 +9,7 @@ type Resource struct { Destroy DestroyFunc Diff DiffFunc Refresh RefreshFunc + Update UpdateFunc } // CreateFunc is a function that creates a resource that didn't previously @@ -35,3 +36,12 @@ type DiffFunc func( type RefreshFunc func( *terraform.ResourceState, 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)