Move alternate image acquisition to separate function

Moves acquisition of an alternate image provided by the user out of
`acquireVMImage` in `pkg/machine/<hypervisor>/machine.go` and into
`pkg/machine/pull.go` as its own function.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
This commit is contained in:
Jake Correnti
2023-08-01 09:53:38 -04:00
parent 906af5bbc6
commit 850482b314
3 changed files with 22 additions and 18 deletions

View File

@ -225,20 +225,11 @@ func (v *MachineVM) acquireVMImage(opts machine.InitOptions) error {
// The user has provided an alternate image which can be a file path
// or URL.
v.ImageStream = "custom"
g, err := machine.NewGenericDownloader(vmtype, v.Name, opts.ImagePath)
imagePath, err := machine.AcquireAlternateImage(v.Name, vmtype, opts)
if err != nil {
return err
}
imagePath, err := machine.NewMachineFile(g.Get().LocalUncompressedFile, nil)
if err != nil {
return err
}
v.ImagePath = *imagePath
if err := machine.DownloadImage(g); err != nil {
return err
}
}
return nil
}