From b9bfae8da3355dd4575c1800df0be80c923b0f60 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 28 May 2015 08:19:53 -0700 Subject: [PATCH] amazon/chroot: style --- builder/amazon/chroot/step_attach_volume.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/builder/amazon/chroot/step_attach_volume.go b/builder/amazon/chroot/step_attach_volume.go index ec3facc10..a7db44b91 100644 --- a/builder/amazon/chroot/step_attach_volume.go +++ b/builder/amazon/chroot/step_attach_volume.go @@ -3,12 +3,13 @@ package chroot import ( "errors" "fmt" + "strings" + "time" + "github.com/mitchellh/goamz/ec2" "github.com/mitchellh/multistep" awscommon "github.com/mitchellh/packer/builder/amazon/common" "github.com/mitchellh/packer/packer" - "strings" - "time" ) // StepAttachVolume attaches the previously created volume to an @@ -51,7 +52,7 @@ func (s *StepAttachVolume) Run(state multistep.StateBag) multistep.StepAction { StepState: state, Target: "attached", Refresh: func() (interface{}, string, error) { - var attempts = 0 + attempts := 0 for attempts < 30 { resp, err := ec2conn.Volumes([]string{volumeId}, ec2.NewFilter()) if err != nil { @@ -63,11 +64,12 @@ func (s *StepAttachVolume) Run(state multistep.StateBag) multistep.StepAction { } // When Attachment on volume is not present sleep for 2s and retry attempts += 1 - ui.Say( - fmt.Sprintf("Warning volume %s show no attachments, Attempt %d/30, Sleeping for 2s and will retry.", - volumeId, attempts)) - time.Sleep(time.Duration(2) * time.Second) + ui.Say(fmt.Sprintf( + "Volume %s show no attachments. Attempt %d/30. Sleeping for 2s and will retry.", + volumeId, attempts)) + time.Sleep(2 * time.Second) } + // Attachment on volume is not present after all attempts return nil, "", errors.New("No attachments on volume.") },