mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-08 23:23:59 -06:00
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:
parent
7c56e33319
commit
43dd13cd36
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user