Skip to content

Commit

Permalink
Fix disk snapshot expand/encode, kmsKeyName decoder (#2450)
Browse files Browse the repository at this point in the history
<!-- This change is generated by MagicModules. -->
/cc @rileykarson
  • Loading branch information
modular-magician authored and nat-henderson committed Dec 21, 2018
1 parent 2249bcd commit 2747376
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
19 changes: 0 additions & 19 deletions google/resource_compute_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
20 changes: 0 additions & 20 deletions google/resource_compute_region_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"fmt"
"log"
"reflect"
"regexp"
"strconv"
"time"

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 2747376

Please sign in to comment.