allow to use ISO images inplace v.s. copying them

This commit is contained in:
Adrien Delorme 2018-08-15 14:37:38 +02:00
parent ce282cee21
commit 82e480a285
5 changed files with 10 additions and 5 deletions

View File

@ -204,6 +204,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
ResultKey: "iso_path",
TargetPath: b.config.TargetPath,
Url: b.config.ISOUrls,
Inplace: b.config.InplaceISO,
},
&vboxcommon.StepOutputDir{
Force: b.config.PackerForce,

View File

@ -291,6 +291,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
ResultKey: "iso_path",
TargetPath: b.config.TargetPath,
Url: b.config.ISOUrls,
Inplace: b.config.InplaceISO,
},
&vmwcommon.StepOutputDir{
Force: b.config.PackerForce,

View File

@ -154,10 +154,7 @@ func (d *DownloadClient) Get() (string, error) {
return "", fmt.Errorf("Unable to treat uri scheme %s as a Downloader. : %T", u.Scheme, d.downloader)
}
local, ok := d.downloader.(LocalDownloader)
if !ok && !d.config.CopyFile {
d.config.CopyFile = true
}
local, _ := d.downloader.(LocalDownloader)
// If we're copying the file, then just use the actual downloader
if d.config.CopyFile {

View File

@ -24,6 +24,7 @@ type ISOConfig struct {
TargetPath string `mapstructure:"iso_target_path"`
TargetExtension string `mapstructure:"iso_target_extension"`
RawSingleISOUrl string `mapstructure:"iso_url"`
InplaceISO bool `mapstructure:"iso_inplace"`
}
func (c *ISOConfig) Prepare(ctx *interpolate.Context) (warnings []string, errs []error) {

View File

@ -45,6 +45,11 @@ type StepDownload struct {
// extension on the URL is used. Otherwise, this will be forced
// on the downloaded file for every URL.
Extension string
// Inplace indicates wether to copy file
// versus using it inplace.
// Inplace is only used when referencing local ISO files.
Inplace bool
}
func (s *StepDownload) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
@ -89,7 +94,7 @@ func (s *StepDownload) Run(_ context.Context, state multistep.StateBag) multiste
config := &DownloadConfig{
Url: url,
TargetPath: targetPath,
CopyFile: false,
CopyFile: !s.Inplace,
Hash: HashForType(s.ChecksumType),
Checksum: checksum,
UserAgent: useragent.String(),