helper/schema: adapt to ID being arg to ImportState
This commit is contained in:
parent
d1a81379d0
commit
2bb814e3de
|
@ -215,7 +215,8 @@ func (p *Provider) Resources() []terraform.ResourceType {
|
|||
}
|
||||
|
||||
func (p *Provider) ImportState(
|
||||
info *terraform.InstanceInfo) ([]*terraform.InstanceState, error) {
|
||||
info *terraform.InstanceInfo,
|
||||
id string) ([]*terraform.InstanceState, error) {
|
||||
// Find the resource
|
||||
r, ok := p.ResourcesMap[info.Type]
|
||||
if !ok {
|
||||
|
@ -229,7 +230,7 @@ func (p *Provider) ImportState(
|
|||
|
||||
// Create the data
|
||||
data := r.Data(nil)
|
||||
data.SetId(info.Id)
|
||||
data.SetId(id)
|
||||
data.SetType(info.Type)
|
||||
|
||||
// Call the import function
|
||||
|
|
|
@ -219,9 +219,8 @@ func TestProviderImportState_setsId(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := p.ImportState(&terraform.InstanceInfo{
|
||||
Id: "bar",
|
||||
Type: "foo",
|
||||
})
|
||||
}, "bar")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -251,7 +250,7 @@ func TestProviderImportState_setsType(t *testing.T) {
|
|||
|
||||
_, err := p.ImportState(&terraform.InstanceInfo{
|
||||
Type: "foo",
|
||||
})
|
||||
}, "bar")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue