From 0e0b467da72320f0cc68c8729b9ab785760a54db Mon Sep 17 00:00:00 2001 From: Ali Rizvi-Santiago Date: Fri, 19 Jan 2018 13:34:01 -0600 Subject: [PATCH] Forgot to check some errors during the adding of files to the floppy disk. This gives users some better information in case packer is unable to add a file...like if there's not enough disk space available. --- common/step_create_floppy.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/step_create_floppy.go b/common/step_create_floppy.go index 5f05eea78..d37302d5c 100644 --- a/common/step_create_floppy.go +++ b/common/step_create_floppy.go @@ -155,7 +155,10 @@ func (s *StepCreateFloppy) Run(state multistep.StateBag) multistep.StepAction { } for _, crawlfilename := range crawlDirectoryFiles { - s.Add(cache, crawlfilename) + if err = s.Add(cache, crawlfilename); err != nil { + state.Put("error", fmt.Errorf("Error adding file from floppy_files : %s : %s", filename, err)) + return multistep.ActionHalt + } s.FilesAdded[crawlfilename] = true } @@ -165,7 +168,10 @@ func (s *StepCreateFloppy) Run(state multistep.StateBag) multistep.StepAction { // add just a single file ui.Message(fmt.Sprintf("Copying file: %s", filename)) - s.Add(cache, filename) + if err = s.Add(cache, filename); err != nil { + state.Put("error", fmt.Errorf("Error adding file from floppy_files : %s : %s", filename, err)) + return multistep.ActionHalt + } s.FilesAdded[filename] = true } ui.Message("Done copying files from floppy_files")