Makes StepDownload's TargetPath customizable.
I exposed TargetPath as a config file option "target_path". I don't like the name, but it follows the naming convention. The purpose of TargetPath stands unmodified, and it enables a fair amount of customization.
This commit is contained in:
parent
e410abdb2c
commit
223e35fc65
|
@ -46,6 +46,7 @@ type Config struct {
|
|||
ISOChecksumType string `mapstructure:"iso_checksum_type"`
|
||||
ISOUrls []string `mapstructure:"iso_urls"`
|
||||
VMName string `mapstructure:"vm_name"`
|
||||
TargetPath string `mapstructure:"target_path"`
|
||||
|
||||
RawSingleISOUrl string `mapstructure:"iso_url"`
|
||||
|
||||
|
@ -218,6 +219,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
Description: "ISO",
|
||||
ResultKey: "iso_path",
|
||||
Url: b.config.ISOUrls,
|
||||
TargetPath: b.config.TargetPath,
|
||||
},
|
||||
¶llelscommon.StepOutputDir{
|
||||
Force: b.config.PackerForce,
|
||||
|
|
|
@ -105,6 +105,7 @@ type Config struct {
|
|||
ShutdownCommand string `mapstructure:"shutdown_command"`
|
||||
SSHHostPortMin uint `mapstructure:"ssh_host_port_min"`
|
||||
SSHHostPortMax uint `mapstructure:"ssh_host_port_max"`
|
||||
TargetPath string `mapstructure:"target_path"`
|
||||
VNCPortMin uint `mapstructure:"vnc_port_min"`
|
||||
VNCPortMax uint `mapstructure:"vnc_port_max"`
|
||||
VMName string `mapstructure:"vm_name"`
|
||||
|
@ -384,6 +385,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
Description: "ISO",
|
||||
ResultKey: "iso_path",
|
||||
Url: b.config.ISOUrls,
|
||||
TargetPath: b.config.TargetPath,
|
||||
},
|
||||
new(stepPrepareOutputDir),
|
||||
&common.StepCreateFloppy{
|
||||
|
|
|
@ -49,6 +49,7 @@ type Config struct {
|
|||
ISOChecksumType string `mapstructure:"iso_checksum_type"`
|
||||
ISOInterface string `mapstructure:"iso_interface"`
|
||||
ISOUrls []string `mapstructure:"iso_urls"`
|
||||
TargetPath string `mapstructure:"target_path"`
|
||||
VMName string `mapstructure:"vm_name"`
|
||||
|
||||
RawSingleISOUrl string `mapstructure:"iso_url"`
|
||||
|
@ -234,6 +235,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
ResultKey: "iso_path",
|
||||
Url: b.config.ISOUrls,
|
||||
Extension: "iso",
|
||||
TargetPath: b.config.TargetPath,
|
||||
},
|
||||
&vboxcommon.StepOutputDir{
|
||||
Force: b.config.PackerForce,
|
||||
|
|
|
@ -49,6 +49,7 @@ type Config struct {
|
|||
VMName string `mapstructure:"vm_name"`
|
||||
BootCommand []string `mapstructure:"boot_command"`
|
||||
SkipCompaction bool `mapstructure:"skip_compaction"`
|
||||
TargetPath string `mapstructure:"target_path"`
|
||||
VMXTemplatePath string `mapstructure:"vmx_template_path"`
|
||||
VMXDiskTemplatePath string `mapstructure:"vmx_disk_template_path"`
|
||||
|
||||
|
@ -260,6 +261,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
Description: "ISO",
|
||||
ResultKey: "iso_path",
|
||||
Url: b.config.ISOUrls,
|
||||
TargetPath: b.config.TargetPath,
|
||||
},
|
||||
&vmwcommon.StepOutputDir{
|
||||
Force: b.config.PackerForce,
|
||||
|
|
|
@ -4,9 +4,10 @@ package common
|
|||
// are sent by packer, properly tagged already so mapstructure can load
|
||||
// them. Embed this structure into your configuration class to get it.
|
||||
type PackerConfig struct {
|
||||
PackerBuildName string `mapstructure:"packer_build_name"`
|
||||
PackerBuilderType string `mapstructure:"packer_builder_type"`
|
||||
PackerDebug bool `mapstructure:"packer_debug"`
|
||||
PackerForce bool `mapstructure:"packer_force"`
|
||||
PackerUserVars map[string]string `mapstructure:"packer_user_variables"`
|
||||
PackerBuildName string `mapstructure:"packer_build_name"`
|
||||
PackerBuilderType string `mapstructure:"packer_builder_type"`
|
||||
PackerDebug bool `mapstructure:"packer_debug"`
|
||||
PackerForce bool `mapstructure:"packer_force"`
|
||||
PackerUserVars map[string]string `mapstructure:"packer_user_variables"`
|
||||
PackerIsoTargetPath string `mapstructure:"packer_iso_target_path"`
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ func (s *StepDownload) Run(state multistep.StateBag) multistep.StepAction {
|
|||
// if we force a certain extension we hash the URL and add
|
||||
// the extension to force it.
|
||||
cacheKey := url
|
||||
if s.Extension != "" {
|
||||
if s.Extension != "" { //HERE.
|
||||
hash := sha1.Sum([]byte(url))
|
||||
cacheKey = fmt.Sprintf(
|
||||
"%s.%s", hex.EncodeToString(hash[:]), s.Extension)
|
||||
|
|
Loading…
Reference in New Issue