github.com/gavinw2006/hashicorp-terraform@v0.11.12-beta1/helper/resource/resource.go (about)

     1  package resource
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/helper/config"
     5  	"github.com/hashicorp/terraform/terraform"
     6  )
     7  
     8  type Resource struct {
     9  	ConfigValidator *config.Validator
    10  	Create          CreateFunc
    11  	Destroy         DestroyFunc
    12  	Diff            DiffFunc
    13  	Refresh         RefreshFunc
    14  	Update          UpdateFunc
    15  }
    16  
    17  // CreateFunc is a function that creates a resource that didn't previously
    18  // exist.
    19  type CreateFunc func(
    20  	*terraform.InstanceState,
    21  	*terraform.InstanceDiff,
    22  	interface{}) (*terraform.InstanceState, error)
    23  
    24  // DestroyFunc is a function that destroys a resource that previously
    25  // exists using the state.
    26  type DestroyFunc func(
    27  	*terraform.InstanceState,
    28  	interface{}) error
    29  
    30  // DiffFunc is a function that performs a diff of a resource.
    31  type DiffFunc func(
    32  	*terraform.InstanceState,
    33  	*terraform.ResourceConfig,
    34  	interface{}) (*terraform.InstanceDiff, error)
    35  
    36  // RefreshFunc is a function that performs a refresh of a specific type
    37  // of resource.
    38  type RefreshFunc func(
    39  	*terraform.InstanceState,
    40  	interface{}) (*terraform.InstanceState, error)
    41  
    42  // UpdateFunc is a function that is called to update a resource that
    43  // previously existed. The difference between this and CreateFunc is that
    44  // the diff is guaranteed to only contain attributes that don't require
    45  // a new resource.
    46  type UpdateFunc func(
    47  	*terraform.InstanceState,
    48  	*terraform.InstanceDiff,
    49  	interface{}) (*terraform.InstanceState, error)