helper/schema: sets Importable to true for resources that have importer
This commit is contained in:
parent
19609bde0e
commit
84531a3fd5
|
@ -197,8 +197,17 @@ func (p *Provider) Resources() []terraform.ResourceType {
|
|||
|
||||
result := make([]terraform.ResourceType, 0, len(keys))
|
||||
for _, k := range keys {
|
||||
resource := p.ResourcesMap[k]
|
||||
|
||||
// This isn't really possible (it'd fail InternalValidate), but
|
||||
// we do it anyways to avoid a panic.
|
||||
if resource == nil {
|
||||
resource = &Resource{}
|
||||
}
|
||||
|
||||
result = append(result, terraform.ResourceType{
|
||||
Name: k,
|
||||
Name: k,
|
||||
Importable: resource.Importer != nil,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,21 @@ func TestProviderResources(t *testing.T) {
|
|||
terraform.ResourceType{Name: "foo"},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
P: &Provider{
|
||||
ResourcesMap: map[string]*Resource{
|
||||
"foo": nil,
|
||||
"bar": &Resource{Importer: &ResourceImporter{}},
|
||||
"baz": nil,
|
||||
},
|
||||
},
|
||||
Result: []terraform.ResourceType{
|
||||
terraform.ResourceType{Name: "bar", Importable: true},
|
||||
terraform.ResourceType{Name: "baz"},
|
||||
terraform.ResourceType{Name: "foo"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
|
|
|
@ -79,7 +79,8 @@ type ResourceProviderCloser interface {
|
|||
|
||||
// ResourceType is a type of resource that a resource provider can manage.
|
||||
type ResourceType struct {
|
||||
Name string
|
||||
Name string // Name of the resource, example "instance" (no provider prefix)
|
||||
Importable bool // Whether this resource supports importing
|
||||
}
|
||||
|
||||
// ResourceProviderFactory is a function type that creates a new instance
|
||||
|
|
Loading…
Reference in New Issue