diff options
author | Jake Champlin <jake.champlin.27@gmail.com> | 2017-06-06 12:40:07 -0400 |
---|---|---|
committer | Jake Champlin <jake.champlin.27@gmail.com> | 2017-06-06 12:40:07 -0400 |
commit | bae9f6d2fd5eb5bc80929bd393932b23f14d7c93 (patch) | |
tree | ca9ab12a7d78b1fc27a8f734729081357ce6d252 /vendor/github.com/hashicorp/terraform/helper/schema/resource_importer.go | |
parent | 254c495b6bebab3fb72a243c4bce858d79e6ee99 (diff) | |
download | terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.tar.gz terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.tar.zst terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.zip |
Initial transfer of provider code
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/helper/schema/resource_importer.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/helper/schema/resource_importer.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/resource_importer.go b/vendor/github.com/hashicorp/terraform/helper/schema/resource_importer.go new file mode 100644 index 0000000..5dada3c --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/helper/schema/resource_importer.go | |||
@@ -0,0 +1,52 @@ | |||
1 | package schema | ||
2 | |||
3 | // ResourceImporter defines how a resource is imported in Terraform. This | ||
4 | // can be set onto a Resource struct to make it Importable. Not all resources | ||
5 | // have to be importable; if a Resource doesn't have a ResourceImporter then | ||
6 | // it won't be importable. | ||
7 | // | ||
8 | // "Importing" in Terraform is the process of taking an already-created | ||
9 | // resource and bringing it under Terraform management. This can include | ||
10 | // updating Terraform state, generating Terraform configuration, etc. | ||
11 | type ResourceImporter struct { | ||
12 | // The functions below must all be implemented for importing to work. | ||
13 | |||
14 | // State is called to convert an ID to one or more InstanceState to | ||
15 | // insert into the Terraform state. If this isn't specified, then | ||
16 | // the ID is passed straight through. | ||
17 | State StateFunc | ||
18 | } | ||
19 | |||
20 | // StateFunc is the function called to import a resource into the | ||
21 | // Terraform state. It is given a ResourceData with only ID set. This | ||
22 | // ID is going to be an arbitrary value given by the user and may not map | ||
23 | // directly to the ID format that the resource expects, so that should | ||
24 | // be validated. | ||
25 | // | ||
26 | // This should return a slice of ResourceData that turn into the state | ||
27 | // that was imported. This might be as simple as returning only the argument | ||
28 | // that was given to the function. In other cases (such as AWS security groups), | ||
29 | // an import may fan out to multiple resources and this will have to return | ||
30 | // multiple. | ||
31 | // | ||
32 | // To create the ResourceData structures for other resource types (if | ||
33 | // you have to), instantiate your resource and call the Data function. | ||
34 | type StateFunc func(*ResourceData, interface{}) ([]*ResourceData, error) | ||
35 | |||
36 | // InternalValidate should be called to validate the structure of this | ||
37 | // importer. This should be called in a unit test. | ||
38 | // | ||
39 | // Resource.InternalValidate() will automatically call this, so this doesn't | ||
40 | // need to be called manually. Further, Resource.InternalValidate() is | ||
41 | // automatically called by Provider.InternalValidate(), so you only need | ||
42 | // to internal validate the provider. | ||
43 | func (r *ResourceImporter) InternalValidate() error { | ||
44 | return nil | ||
45 | } | ||
46 | |||
47 | // ImportStatePassthrough is an implementation of StateFunc that can be | ||
48 | // used to simply pass the ID directly through. This should be used only | ||
49 | // in the case that an ID-only refresh is possible. | ||
50 | func ImportStatePassthrough(d *ResourceData, m interface{}) ([]*ResourceData, error) { | ||
51 | return []*ResourceData{d}, nil | ||
52 | } | ||