a3f0308e92
Moved the support for recursive paths from the floppy_files keyword to the new floppy_contents keyword. Shifted some of the code around to add better logging of what's actually being copied. Added a couple of unit-tests for the new floppy_contents implementation. Ensured that all files that were being added were also being included in state.FilesAdded so that the older unit-tests will work.
40 lines
822 B
Go
40 lines
822 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/mitchellh/packer/template/interpolate"
|
|
)
|
|
|
|
type FloppyConfig struct {
|
|
FloppyFiles []string `mapstructure:"floppy_files"`
|
|
FloppyContents []string `mapstructure:"floppy_contents"`
|
|
}
|
|
|
|
func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error {
|
|
var errs []error
|
|
|
|
if c.FloppyFiles == nil {
|
|
c.FloppyFiles = make([]string, 0)
|
|
}
|
|
|
|
for _, path := range c.FloppyFiles {
|
|
if _, err := os.Stat(path); err != nil {
|
|
errs = append(errs, fmt.Errorf("Bad Floppy disk file '%s': %s", path, err))
|
|
}
|
|
}
|
|
|
|
if c.FloppyContents == nil {
|
|
c.FloppyContents = make([]string, 0)
|
|
}
|
|
|
|
for _, path := range c.FloppyContents {
|
|
if _, err := os.Stat(path); err != nil {
|
|
errs = append(errs, fmt.Errorf("Bad Floppy disk directory '%s': %s", path, err))
|
|
}
|
|
}
|
|
|
|
return errs
|
|
}
|