From 27473768d4b293de2f6e6a960ef0c70179a80ee2 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 12 Nov 2018 11:17:56 -0800 Subject: [PATCH] Fix disk snapshot expand/encode, kmsKeyName decoder (#2450) /cc @rileykarson --- google/resource_compute_disk.go | 19 ------------------- google/resource_compute_region_disk.go | 20 -------------------- 2 files changed, 39 deletions(-) diff --git a/google/resource_compute_disk.go b/google/resource_compute_disk.go index 5c4f7c65e19..abf25a33bf8 100644 --- a/google/resource_compute_disk.go +++ b/google/resource_compute_disk.go @@ -1182,25 +1182,6 @@ func resourceComputeDiskEncoder(d *schema.ResourceData, meta interface{}, obj ma log.Printf("[DEBUG] Image name resolved to: %s", imageUrl) } - if v, ok := d.GetOk("snapshot"); ok { - snapshotName := v.(string) - match, _ := regexp.MatchString("^https://www.googleapis.com/compute", snapshotName) - if match { - obj["sourceSnapshot"] = snapshotName - } else { - log.Printf("[DEBUG] Loading snapshot: %s", snapshotName) - snapshotData, err := config.clientCompute.Snapshots.Get( - project, snapshotName).Do() - - if err != nil { - return nil, fmt.Errorf( - "Error loading snapshot '%s': %s", - snapshotName, err) - } - obj["sourceSnapshot"] = snapshotData.SelfLink - } - } - return obj, nil } diff --git a/google/resource_compute_region_disk.go b/google/resource_compute_region_disk.go index d577c85975c..aba872a6155 100644 --- a/google/resource_compute_region_disk.go +++ b/google/resource_compute_region_disk.go @@ -18,7 +18,6 @@ import ( "fmt" "log" "reflect" - "regexp" "strconv" "time" @@ -863,25 +862,6 @@ func resourceComputeRegionDiskEncoder(d *schema.ResourceData, meta interface{}, log.Printf("[DEBUG] Image name resolved to: %s", imageUrl) } - if v, ok := d.GetOk("snapshot"); ok { - snapshotName := v.(string) - match, _ := regexp.MatchString("^https://www.googleapis.com/compute", snapshotName) - if match { - obj["sourceSnapshot"] = snapshotName - } else { - log.Printf("[DEBUG] Loading snapshot: %s", snapshotName) - snapshotData, err := config.clientCompute.Snapshots.Get( - project, snapshotName).Do() - - if err != nil { - return nil, fmt.Errorf( - "Error loading snapshot '%s': %s", - snapshotName, err) - } - obj["sourceSnapshot"] = snapshotData.SelfLink - } - } - return obj, nil }