forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource.go
49 lines (42 loc) · 1.4 KB
/
resource.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package resource
import (
"github.com/hashicorp/terraform/helper/config"
"github.com/hashicorp/terraform/terraform"
)
type Resource struct {
ConfigValidator *config.Validator
Create CreateFunc
Destroy DestroyFunc
Diff DiffFunc
Refresh RefreshFunc
Update UpdateFunc
}
// CreateFunc is a function that creates a resource that didn't previously
// exist.
type CreateFunc func(
*terraform.ResourceState,
*terraform.ResourceDiff,
interface{}) (*terraform.ResourceState, error)
// DestroyFunc is a function that destroys a resource that previously
// exists using the state.
type DestroyFunc func(
*terraform.ResourceState,
interface{}) error
// DiffFunc is a function that performs a diff of a resource.
type DiffFunc func(
*terraform.ResourceState,
*terraform.ResourceConfig,
interface{}) (*terraform.ResourceDiff, error)
// RefreshFunc is a function that performs a refresh of a specific type
// of resource.
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)