Look up snapshot ID based by Droplet, not user.

This commit is contained in:
Andrew Starr-Bochicchio 2016-02-09 11:29:06 -05:00
parent 7fa5bcd5d7
commit 6d31470757
1 changed files with 4 additions and 9 deletions

View File

@ -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())