github.com/homburg/packer@v0.6.1-0.20140528012651-1dcaf1716848/builder/vmware/iso/step_remote_upload.go (about) 1 package iso 2 3 import ( 4 "fmt" 5 "github.com/mitchellh/multistep" 6 vmwcommon "github.com/mitchellh/packer/builder/vmware/common" 7 "github.com/mitchellh/packer/packer" 8 "log" 9 ) 10 11 // stepRemoteUpload uploads some thing from the state bag to a remote driver 12 // (if it can) and stores that new remote path into the state bag. 13 type stepRemoteUpload struct { 14 Key string 15 Message string 16 } 17 18 func (s *stepRemoteUpload) Run(state multistep.StateBag) multistep.StepAction { 19 driver := state.Get("driver").(vmwcommon.Driver) 20 ui := state.Get("ui").(packer.Ui) 21 22 remote, ok := driver.(RemoteDriver) 23 if !ok { 24 return multistep.ActionContinue 25 } 26 27 path, ok := state.Get(s.Key).(string) 28 if !ok { 29 return multistep.ActionContinue 30 } 31 32 ui.Say(s.Message) 33 log.Printf("Remote uploading: %s", path) 34 newPath, err := remote.UploadISO(path) 35 if err != nil { 36 err := fmt.Errorf("Error uploading file: %s", err) 37 state.Put("error", err) 38 ui.Error(err.Error()) 39 return multistep.ActionHalt 40 } 41 42 state.Put(s.Key, newPath) 43 return multistep.ActionContinue 44 } 45 46 func (s *stepRemoteUpload) Cleanup(state multistep.StateBag) { 47 }