helper/schema: Introduce Noop and RemoveFromState

This commit implements reusable functions for when resources have no
need to implement a particular operation:

- Noop - does nothing and returns no error.
- RemoveFromState - sets the resource ID to empty string (removing it
  from state) and returns no error.
This commit is contained in:
James Nugent 2016-10-25 11:45:39 -05:00
parent 7c56e33319
commit 43dd13cd36
1 changed files with 14 additions and 0 deletions

View File

@ -384,3 +384,17 @@ func (r *Resource) recordCurrentSchemaVersion(
}
return state
}
// Noop is a convenience implementation of resource function which takes
// no action and returns no error.
func Noop(*ResourceData, interface{}) error {
return nil
}
// RemoveFromState is a convenience implementation of a resource function
// which sets the resource ID to empty string (to remove it from state)
// and returns no error.
func RemoveFromState(d *ResourceData, _ interface{}) error {
d.SetId("")
return nil
}