Look up snapshot ID based by Droplet, not user.
This commit is contained in:
parent
7fa5bcd5d7
commit
6d31470757
|
@ -50,7 +50,7 @@ func (s *stepSnapshot) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Looking up snapshot ID for snapshot: %s", c.SnapshotName)
|
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 {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error looking up snapshot ID: %s", err)
|
err := fmt.Errorf("Error looking up snapshot ID: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
@ -59,14 +59,9 @@ func (s *stepSnapshot) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
var imageId int
|
var imageId int
|
||||||
for _, image := range images {
|
if len(images) == 1 {
|
||||||
if image.Name == c.SnapshotName {
|
imageId = images[0].ID
|
||||||
imageId = image.ID
|
} else {
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if imageId == 0 {
|
|
||||||
err := errors.New("Couldn't find snapshot to get the image ID. Bug?")
|
err := errors.New("Couldn't find snapshot to get the image ID. Bug?")
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
|
|
Loading…
Reference in New Issue