mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
Changed Bigtable instance to use InstanceInfo instead of iterating the list of infos.
This commit is contained in:
parent
cfe9e4afb4
commit
ec2f933252
@ -132,27 +132,13 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro
|
||||
|
||||
defer c.Close()
|
||||
|
||||
instances, err := c.Instances(ctx)
|
||||
instance, err := c.InstanceInfo(ctx, d.Id())
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error retrieving instances. %s", err)
|
||||
return fmt.Errorf("Error retrieving instance. Could not find %s.", d.Id())
|
||||
}
|
||||
|
||||
var instanceInfo *bigtable.InstanceInfo
|
||||
name := d.Id()
|
||||
found := false
|
||||
for _, i := range instances {
|
||||
if i.Name == name {
|
||||
instanceInfo = i
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return fmt.Errorf("Error retrieving instance. Could not find %s.", name)
|
||||
}
|
||||
|
||||
d.Set("name", instanceInfo.Name)
|
||||
d.Set("display_name", instanceInfo.DisplayName)
|
||||
d.Set("name", instance.Name)
|
||||
d.Set("display_name", instance.DisplayName)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -42,20 +42,8 @@ func testAccCheckBigtableInstanceDestroy(s *terraform.State) error {
|
||||
return fmt.Errorf("Error starting instance admin client. %s", err)
|
||||
}
|
||||
|
||||
instances, err := c.Instances(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error retrieving instances. %s", err)
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, i := range instances {
|
||||
if i.Name == rs.Primary.Attributes["name"] {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if found {
|
||||
_, err = c.InstanceInfo(ctx, rs.Primary.Attributes["name"])
|
||||
if err == nil {
|
||||
return fmt.Errorf("Instance %s still exists.", rs.Primary.Attributes["name"])
|
||||
}
|
||||
|
||||
@ -82,20 +70,8 @@ func testAccBigtableInstanceExists(n string) resource.TestCheckFunc {
|
||||
return fmt.Errorf("Error starting instance admin client. %s", err)
|
||||
}
|
||||
|
||||
instances, err := c.Instances(ctx)
|
||||
_, err = c.InstanceInfo(ctx, rs.Primary.Attributes["name"])
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error retrieving instances. %s", err)
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, i := range instances {
|
||||
if i.Name == rs.Primary.Attributes["name"] {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return fmt.Errorf("Error retrieving instance %s.", rs.Primary.Attributes["name"])
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user