2014-06-24 04:32:49 +02:00
|
|
|
package resource
|
|
|
|
|
|
|
|
import (
|
2014-07-08 19:17:36 +02:00
|
|
|
"github.com/hashicorp/terraform/helper/config"
|
2014-06-24 04:32:49 +02:00
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Resource struct {
|
2014-07-08 19:17:36 +02:00
|
|
|
ConfigValidator *config.Validator
|
|
|
|
Create CreateFunc
|
|
|
|
Destroy DestroyFunc
|
|
|
|
Diff DiffFunc
|
|
|
|
Refresh RefreshFunc
|
|
|
|
Update UpdateFunc
|
2014-06-24 04:32:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateFunc is a function that creates a resource that didn't previously
|
|
|
|
// exist.
|
|
|
|
type CreateFunc func(
|
2014-09-17 02:02:05 +02:00
|
|
|
*terraform.InstanceState,
|
2014-06-24 04:32:49 +02:00
|
|
|
*terraform.ResourceDiff,
|
2014-09-17 02:02:05 +02:00
|
|
|
interface{}) (*terraform.InstanceState, error)
|
2014-06-24 04:32:49 +02:00
|
|
|
|
2014-06-24 19:22:22 +02:00
|
|
|
// DestroyFunc is a function that destroys a resource that previously
|
|
|
|
// exists using the state.
|
|
|
|
type DestroyFunc func(
|
2014-09-17 02:02:05 +02:00
|
|
|
*terraform.InstanceState,
|
2014-06-24 19:22:22 +02:00
|
|
|
interface{}) error
|
|
|
|
|
2014-06-24 04:32:49 +02:00
|
|
|
// DiffFunc is a function that performs a diff of a resource.
|
|
|
|
type DiffFunc func(
|
2014-09-17 02:02:05 +02:00
|
|
|
*terraform.InstanceState,
|
2014-06-24 04:32:49 +02:00
|
|
|
*terraform.ResourceConfig,
|
|
|
|
interface{}) (*terraform.ResourceDiff, error)
|
|
|
|
|
|
|
|
// RefreshFunc is a function that performs a refresh of a specific type
|
|
|
|
// of resource.
|
|
|
|
type RefreshFunc func(
|
2014-09-17 02:02:05 +02:00
|
|
|
*terraform.InstanceState,
|
|
|
|
interface{}) (*terraform.InstanceState, error)
|
2014-07-03 02:31:58 +02:00
|
|
|
|
|
|
|
// 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(
|
2014-09-17 02:02:05 +02:00
|
|
|
*terraform.InstanceState,
|
2014-07-03 02:31:58 +02:00
|
|
|
*terraform.ResourceDiff,
|
2014-09-17 02:02:05 +02:00
|
|
|
interface{}) (*terraform.InstanceState, error)
|