Add calling code and skeleton driver to make tests pass

This commit is contained in:
DanHam 2018-07-08 17:22:27 +01:00
parent 0a4ec13323
commit 181bb0ba23
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
3 changed files with 20 additions and 3 deletions

View File

@ -96,6 +96,8 @@ type Driver interface {
PreserveLegacyExportBehaviour(string, string) error
MoveCreatedVHDsToOutputDir(string, string) error
CompactDisks(string) (string, error)
RestartVirtualMachine(string) error

View File

@ -223,6 +223,12 @@ func (d *HypervPS4Driver) PreserveLegacyExportBehaviour(srcPath string, dstPath
return hyperv.PreserveLegacyExportBehaviour(srcPath, dstPath)
}
func (d *HypervPS4Driver) MoveCreatedVHDsToOutputDir(srcPath string, dstPath string) error {
// Not implemented yet
err := fmt.Errorf("Not implemented yet")
return err
}
func (d *HypervPS4Driver) CompactDisks(path string) (result string, err error) {
return hyperv.CompactDisks(path)
}

View File

@ -22,11 +22,20 @@ func (s *StepCollateArtifacts) Run(_ context.Context, state multistep.StateBag)
ui.Say("Collating build artifacts...")
if s.SkipExport {
// Get the path to the main build directory from the statebag
var packerTempDir string
if v, ok := state.GetOk("packerTempDir"); ok {
packerTempDir = v.(string)
}
// If the user has chosen to skip a full export of the VM the only
// artifacts that they are interested in will be the VHDs
// TODO: Grab the disks from the build directory and place them in
// a folder named 'Virtual Hard Disks' under the output directory
err := driver.MoveCreatedVHDsToOutputDir(packerTempDir, s.OutputDir)
if err != nil {
err = fmt.Errorf("Error moving VHDs from build dir to output dir: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
} else {
// Get the full path to the export directory from the statebag
var exportPath string