@@ -7,10 +7,13 @@ import (
77)
88
99// The functions below are the CRUD function types for a Resource.
10- type CreateFunc func (* ResourceData ) error
11- type ReadFunc func (* ResourceData ) error
12- type UpdateFunc func (* ResourceData ) error
13- type DeleteFunc func (* ResourceData ) error
10+ //
11+ // The second parameter is the meta value sent to the resource when
12+ // different operations are called.
13+ type CreateFunc func (* ResourceData , interface {}) error
14+ type ReadFunc func (* ResourceData , interface {}) error
15+ type UpdateFunc func (* ResourceData , interface {}) error
16+ type DeleteFunc func (* ResourceData , interface {}) error
1417
1518// Resource represents a thing in Terraform that has a set of configurable
1619// attributes and generally also has a lifecycle (create, read, update,
@@ -41,6 +44,19 @@ func (r *Resource) Validate(c *terraform.ResourceConfig) ([]string, []error) {
4144 return schemaMap (r .Schema ).Validate (c )
4245}
4346
47+ // Refresh refreshes the state of the resource.
48+ func (r * Resource ) Refresh (
49+ s * terraform.ResourceState ,
50+ meta interface {}) (* terraform.ResourceState , error ) {
51+ data , err := schemaMap (r .Schema ).Data (s , nil )
52+ if err != nil {
53+ return nil , err
54+ }
55+
56+ err = r .Read (data , meta )
57+ return data .State (), err
58+ }
59+
4460// InternalValidate should be called to validate the structure
4561// of the resource.
4662//
0 commit comments