From 6d314707570489e5216d6d69931816eb7f367c4f Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Tue, 9 Feb 2016 11:29:06 -0500 Subject: [PATCH] Look up snapshot ID based by Droplet, not user. --- builder/digitalocean/step_snapshot.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/builder/digitalocean/step_snapshot.go b/builder/digitalocean/step_snapshot.go index 3ff4583b7..8974ad23f 100644 --- a/builder/digitalocean/step_snapshot.go +++ b/builder/digitalocean/step_snapshot.go @@ -50,7 +50,7 @@ func (s *stepSnapshot) Run(state multistep.StateBag) multistep.StepAction { } log.Printf("Looking up snapshot ID for snapshot: %s", c.SnapshotName) - images, _, err := client.Images.ListUser(&godo.ListOptions{PerPage: 200}) + images, _, err := client.Droplets.Snapshots(dropletId, nil) if err != nil { err := fmt.Errorf("Error looking up snapshot ID: %s", err) state.Put("error", err) @@ -59,14 +59,9 @@ func (s *stepSnapshot) Run(state multistep.StateBag) multistep.StepAction { } var imageId int - for _, image := range images { - if image.Name == c.SnapshotName { - imageId = image.ID - break - } - } - - if imageId == 0 { + if len(images) == 1 { + imageId = images[0].ID + } else { err := errors.New("Couldn't find snapshot to get the image ID. Bug?") state.Put("error", err) ui.Error(err.Error())