mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-04 17:51:11 +00:00
Correct issue with Disk encryption. (#1584)
* Correct issue with Disk encryption. * Update to test to make it less permissive.
This commit is contained in:
parent
dd92a3732e
commit
b85473619c
@ -236,10 +236,10 @@ func diskEncryptionKeyDiffSuppress(k, old, new string, d *schema.ResourceData) b
|
|||||||
}
|
}
|
||||||
} else if strings.HasSuffix(k, "raw_key") {
|
} else if strings.HasSuffix(k, "raw_key") {
|
||||||
disk_key := d.Get("disk_encryption_key_raw").(string)
|
disk_key := d.Get("disk_encryption_key_raw").(string)
|
||||||
return disk_key == old
|
return disk_key == old && old != "" && new == ""
|
||||||
} else if k == "disk_encryption_key_raw" {
|
} else if k == "disk_encryption_key_raw" {
|
||||||
disk_key := d.Get("disk_encryption_key.0.raw_key").(string)
|
disk_key := d.Get("disk_encryption_key.0.raw_key").(string)
|
||||||
return disk_key == old
|
return disk_key == old && old != "" && new == ""
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -1004,7 +1004,7 @@ func expandComputeDiskDiskEncryptionKey(v interface{}, d *schema.ResourceData, c
|
|||||||
req = append(req, outMap)
|
req = append(req, outMap)
|
||||||
} else {
|
} else {
|
||||||
// Check alternative setting?
|
// Check alternative setting?
|
||||||
if altV, ok := d.GetOk("disk_encryption_key_raw"); ok {
|
if altV, ok := d.GetOk("disk_encryption_key_raw"); ok && altV != "" {
|
||||||
outMap := make(map[string]interface{})
|
outMap := make(map[string]interface{})
|
||||||
outMap["rawKey"] = altV
|
outMap["rawKey"] = altV
|
||||||
req = append(req, outMap)
|
req = append(req, outMap)
|
||||||
|
@ -566,9 +566,9 @@ func testAccCheckEncryptionKey(n string, disk *compute.Disk) resource.TestCheckF
|
|||||||
}
|
}
|
||||||
|
|
||||||
attr := rs.Primary.Attributes["disk_encryption_key_sha256"]
|
attr := rs.Primary.Attributes["disk_encryption_key_sha256"]
|
||||||
if disk.DiskEncryptionKey == nil && attr != "" {
|
if disk.DiskEncryptionKey == nil {
|
||||||
return fmt.Errorf("Disk %s has mismatched encryption key.\nTF State: %+v\nGCP State: <empty>", n, attr)
|
return fmt.Errorf("Disk %s has mismatched encryption key.\nTF State: %+v\nGCP State: <empty>", n, attr)
|
||||||
} else if disk.DiskEncryptionKey != nil && attr != disk.DiskEncryptionKey.Sha256 {
|
} else if attr != disk.DiskEncryptionKey.Sha256 {
|
||||||
return fmt.Errorf("Disk %s has mismatched encryption key.\nTF State: %+v.\nGCP State: %+v",
|
return fmt.Errorf("Disk %s has mismatched encryption key.\nTF State: %+v.\nGCP State: %+v",
|
||||||
n, attr, disk.DiskEncryptionKey.Sha256)
|
n, attr, disk.DiskEncryptionKey.Sha256)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user