provider/google: changed the format of source_image in autoscaler tests

This commit is contained in:
Noah Webb 2016-08-19 13:55:30 -04:00
parent 3af67964dc
commit 679b063a30
3 changed files with 17 additions and 12 deletions

View File

@ -139,7 +139,7 @@ resource "google_compute_instance_template" "foobar" {
tags = ["foo", "bar"]
disk {
source_image = "debian-8-jessie-v20160803"
source_image = "debian-cloud/debian-7-wheezy-v20160301"
auto_delete = true
boot = true
}
@ -196,7 +196,7 @@ resource "google_compute_instance_template" "foobar" {
tags = ["foo", "bar"]
disk {
source_image = "debian-8-jessie-v20160803"
source_image = "debian-cloud/debian-7-wheezy-v20160301"
auto_delete = true
boot = true
}

View File

@ -277,7 +277,7 @@ func testAccInstanceGroupManager_basic(template, target, igm1, igm2 string) stri
tags = ["foo", "bar"]
disk {
source_image = "debian-8-jessie-v20160803"
source_image = "debian-cloud/debian-7-wheezy-v20160301"
auto_delete = true
boot = true
}
@ -331,7 +331,7 @@ func testAccInstanceGroupManager_update(template, target, igm string) string {
tags = ["foo", "bar"]
disk {
source_image = "debian-8-jessie-v20160803"
source_image = "debian-cloud/debian-7-wheezy-v20160301"
auto_delete = true
boot = true
}
@ -380,7 +380,7 @@ func testAccInstanceGroupManager_update2(template1, target, template2, igm strin
tags = ["foo", "bar"]
disk {
source_image = "debian-8-jessie-v20160803"
source_image = "debian-cloud/debian-7-wheezy-v20160301"
auto_delete = true
boot = true
}
@ -411,7 +411,7 @@ func testAccInstanceGroupManager_update2(template1, target, template2, igm strin
tags = ["foo", "bar"]
disk {
source_image = "debian-8-jessie-v20160803"
source_image = "debian-cloud/debian-7-wheezy-v20160301"
auto_delete = true
boot = true
}
@ -456,7 +456,7 @@ func testAccInstanceGroupManager_updateLifecycle(tag, igm string) string {
tags = ["%s"]
disk {
source_image = "debian-8-jessie-v20160803"
source_image = "debian-cloud/debian-7-wheezy-v20160301"
auto_delete = true
boot = true
}

View File

@ -585,13 +585,18 @@ func resourceComputeInstanceTemplateCreate(d *schema.ResourceData, meta interfac
return resourceComputeInstanceTemplateRead(d, meta)
}
func flattenDisks(disks []*compute.AttachedDisk) []map[string]interface{} {
func flattenDisks(disks []*compute.AttachedDisk, d *schema.ResourceData) []map[string]interface{} {
result := make([]map[string]interface{}, 0, len(disks))
for _, disk := range disks {
for i, disk := range disks {
diskMap := make(map[string]interface{})
if disk.InitializeParams != nil {
sourceImageUrl := strings.Split(disk.InitializeParams.SourceImage, "/")
diskMap["source_image"] = sourceImageUrl[len(sourceImageUrl)-1]
var source_img = fmt.Sprintf("disk.%d.source_image", i)
if d.Get(source_img) == nil || d.Get(source_img) == "" {
sourceImageUrl := strings.Split(disk.InitializeParams.SourceImage, "/")
diskMap["source_image"] = sourceImageUrl[len(sourceImageUrl)-1]
} else {
diskMap["source_image"] = d.Get(source_img)
}
diskMap["disk_type"] = disk.InitializeParams.DiskType
diskMap["disk_name"] = disk.InitializeParams.DiskName
diskMap["disk_size_gb"] = disk.InitializeParams.DiskSizeGb
@ -701,7 +706,7 @@ func resourceComputeInstanceTemplateRead(d *schema.ResourceData, meta interface{
d.Set("self_link", instanceTemplate.SelfLink)
d.Set("name", instanceTemplate.Name)
if instanceTemplate.Properties.Disks != nil {
d.Set("disk", flattenDisks(instanceTemplate.Properties.Disks))
d.Set("disk", flattenDisks(instanceTemplate.Properties.Disks, d))
}
d.Set("description", instanceTemplate.Description)
d.Set("machine_type", instanceTemplate.Properties.MachineType)