mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-01 07:42:40 +00:00
This reverts commit 19402eb4f0
.
This commit is contained in:
parent
19402eb4f0
commit
b1abc676a9
|
@ -379,17 +379,12 @@ func resourceComputeInstanceGroupDelete(d *schema.ResourceData, meta interface{}
|
||||||
|
|
||||||
func resourceComputeInstanceGroupImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
func resourceComputeInstanceGroupImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||||
parts := strings.Split(d.Id(), "/")
|
parts := strings.Split(d.Id(), "/")
|
||||||
if len(parts) == 2 {
|
if len(parts) != 2 {
|
||||||
d.Set("zone", parts[0])
|
return nil, fmt.Errorf("Invalid compute instance group specifier. Expecting {zone}/{name}")
|
||||||
d.Set("name", parts[1])
|
|
||||||
} else if len(parts) == 3 {
|
|
||||||
d.Set("project", parts[0])
|
|
||||||
d.Set("zone", parts[1])
|
|
||||||
d.Set("name", parts[2])
|
|
||||||
d.SetId(parts[1] + "/" + parts[2])
|
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("Invalid compute instance group specifier. Expecting {zone}/{name} or {project}/{zone}/{name}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.Set("zone", parts[0])
|
||||||
|
d.Set("name", parts[1])
|
||||||
|
|
||||||
return []*schema.ResourceData{d}, nil
|
return []*schema.ResourceData{d}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,7 @@ func TestAccComputeInstanceGroup_basic(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
var instanceGroup compute.InstanceGroup
|
var instanceGroup compute.InstanceGroup
|
||||||
var resourceName = "google_compute_instance_group.basic"
|
|
||||||
var instanceName = fmt.Sprintf("instancegroup-test-%s", acctest.RandString(10))
|
var instanceName = fmt.Sprintf("instancegroup-test-%s", acctest.RandString(10))
|
||||||
var zone = "us-central1-c"
|
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
@ -25,7 +23,7 @@ func TestAccComputeInstanceGroup_basic(t *testing.T) {
|
||||||
CheckDestroy: testAccComputeInstanceGroup_destroy,
|
CheckDestroy: testAccComputeInstanceGroup_destroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccComputeInstanceGroup_basic(zone, instanceName),
|
Config: testAccComputeInstanceGroup_basic(instanceName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccComputeInstanceGroup_exists(
|
testAccComputeInstanceGroup_exists(
|
||||||
"google_compute_instance_group.basic", &instanceGroup),
|
"google_compute_instance_group.basic", &instanceGroup),
|
||||||
|
@ -34,16 +32,10 @@ func TestAccComputeInstanceGroup_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ResourceName: resourceName,
|
ResourceName: "google_compute_instance_group.basic",
|
||||||
ImportState: true,
|
ImportState: true,
|
||||||
ImportStateVerify: true,
|
ImportStateVerify: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
ResourceName: resourceName,
|
|
||||||
ImportState: true,
|
|
||||||
ImportStateVerify: true,
|
|
||||||
ImportStateId: fmt.Sprintf("%s/%s/%s", getTestProjectFromEnv(), zone, instanceName),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -315,7 +307,7 @@ func testAccComputeInstanceGroup_hasCorrectNetwork(nInstanceGroup string, nNetwo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccComputeInstanceGroup_basic(zone, instance string) string {
|
func testAccComputeInstanceGroup_basic(instance string) string {
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
data "google_compute_image" "my_image" {
|
data "google_compute_image" "my_image" {
|
||||||
family = "debian-9"
|
family = "debian-9"
|
||||||
|
@ -342,7 +334,7 @@ func testAccComputeInstanceGroup_basic(zone, instance string) string {
|
||||||
resource "google_compute_instance_group" "basic" {
|
resource "google_compute_instance_group" "basic" {
|
||||||
description = "Terraform test instance group"
|
description = "Terraform test instance group"
|
||||||
name = "%s"
|
name = "%s"
|
||||||
zone = "%s"
|
zone = "us-central1-c"
|
||||||
instances = [ "${google_compute_instance.ig_instance.self_link}" ]
|
instances = [ "${google_compute_instance.ig_instance.self_link}" ]
|
||||||
named_port {
|
named_port {
|
||||||
name = "http"
|
name = "http"
|
||||||
|
@ -357,7 +349,7 @@ func testAccComputeInstanceGroup_basic(zone, instance string) string {
|
||||||
resource "google_compute_instance_group" "empty" {
|
resource "google_compute_instance_group" "empty" {
|
||||||
description = "Terraform test instance group empty"
|
description = "Terraform test instance group empty"
|
||||||
name = "%s-empty"
|
name = "%s-empty"
|
||||||
zone = "%s"
|
zone = "us-central1-c"
|
||||||
named_port {
|
named_port {
|
||||||
name = "http"
|
name = "http"
|
||||||
port = "8080"
|
port = "8080"
|
||||||
|
@ -366,7 +358,7 @@ func testAccComputeInstanceGroup_basic(zone, instance string) string {
|
||||||
name = "https"
|
name = "https"
|
||||||
port = "8443"
|
port = "8443"
|
||||||
}
|
}
|
||||||
}`, instance, instance, zone, instance, zone)
|
}`, instance, instance, instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccComputeInstanceGroup_rename(instance, instanceGroup, backend, health string) string {
|
func testAccComputeInstanceGroup_rename(instance, instanceGroup, backend, health string) string {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user