fmt
This commit is contained in:
parent
f8617b2641
commit
1e7508c828
|
@ -25,31 +25,31 @@ type Builder struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
BootCommand []string `mapstructure:"boot_command"`
|
BootCommand []string `mapstructure:"boot_command"`
|
||||||
BootWait time.Duration ``
|
BootWait time.Duration ``
|
||||||
DiskSize uint `mapstructure:"disk_size"`
|
DiskSize uint `mapstructure:"disk_size"`
|
||||||
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
||||||
GuestAdditionsURL string `mapstructure:"guest_additions_url"`
|
GuestAdditionsURL string `mapstructure:"guest_additions_url"`
|
||||||
GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
|
GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
|
||||||
GuestOSType string `mapstructure:"guest_os_type"`
|
GuestOSType string `mapstructure:"guest_os_type"`
|
||||||
Headless bool `mapstructure:"headless"`
|
Headless bool `mapstructure:"headless"`
|
||||||
HTTPDir string `mapstructure:"http_directory"`
|
HTTPDir string `mapstructure:"http_directory"`
|
||||||
HTTPPortMin uint `mapstructure:"http_port_min"`
|
HTTPPortMin uint `mapstructure:"http_port_min"`
|
||||||
HTTPPortMax uint `mapstructure:"http_port_max"`
|
HTTPPortMax uint `mapstructure:"http_port_max"`
|
||||||
ISOMD5 string `mapstructure:"iso_md5"`
|
ISOMD5 string `mapstructure:"iso_md5"`
|
||||||
ISOUrl string `mapstructure:"iso_url"`
|
ISOUrl string `mapstructure:"iso_url"`
|
||||||
OutputDir string `mapstructure:"output_directory"`
|
OutputDir string `mapstructure:"output_directory"`
|
||||||
ShutdownCommand string `mapstructure:"shutdown_command"`
|
ShutdownCommand string `mapstructure:"shutdown_command"`
|
||||||
ShutdownTimeout time.Duration ``
|
ShutdownTimeout time.Duration ``
|
||||||
SSHHostPortMin uint `mapstructure:"ssh_host_port_min"`
|
SSHHostPortMin uint `mapstructure:"ssh_host_port_min"`
|
||||||
SSHHostPortMax uint `mapstructure:"ssh_host_port_max"`
|
SSHHostPortMax uint `mapstructure:"ssh_host_port_max"`
|
||||||
SSHPassword string `mapstructure:"ssh_password"`
|
SSHPassword string `mapstructure:"ssh_password"`
|
||||||
SSHPort uint `mapstructure:"ssh_port"`
|
SSHPort uint `mapstructure:"ssh_port"`
|
||||||
SSHUser string `mapstructure:"ssh_username"`
|
SSHUser string `mapstructure:"ssh_username"`
|
||||||
SSHWaitTimeout time.Duration ``
|
SSHWaitTimeout time.Duration ``
|
||||||
VBoxVersionFile string `mapstructure:"virtualbox_version_file"`
|
VBoxVersionFile string `mapstructure:"virtualbox_version_file"`
|
||||||
VBoxManage [][]string `mapstructure:"vboxmanage"`
|
VBoxManage [][]string `mapstructure:"vboxmanage"`
|
||||||
VMName string `mapstructure:"vm_name"`
|
VMName string `mapstructure:"vm_name"`
|
||||||
|
|
||||||
PackerBuildName string `mapstructure:"packer_build_name"`
|
PackerBuildName string `mapstructure:"packer_build_name"`
|
||||||
PackerDebug bool `mapstructure:"packer_debug"`
|
PackerDebug bool `mapstructure:"packer_debug"`
|
||||||
|
|
|
@ -216,7 +216,6 @@ func TestBuilderPrepare_GuestAdditionsURL(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestBuilderPrepare_HTTPPort(t *testing.T) {
|
func TestBuilderPrepare_HTTPPort(t *testing.T) {
|
||||||
var b Builder
|
var b Builder
|
||||||
config := testConfig()
|
config := testConfig()
|
||||||
|
|
|
@ -35,7 +35,7 @@ func (s *stepDownloadGuestAdditions) Run(state map[string]interface{}) multistep
|
||||||
ui := state["ui"].(packer.Ui)
|
ui := state["ui"].(packer.Ui)
|
||||||
config := state["config"].(*config)
|
config := state["config"].(*config)
|
||||||
|
|
||||||
// Get VBox version
|
// Get VBox version
|
||||||
version, err := driver.Version()
|
version, err := driver.Version()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state["error"] = fmt.Errorf("Error reading version for guest additions download: %s", err)
|
state["error"] = fmt.Errorf("Error reading version for guest additions download: %s", err)
|
||||||
|
@ -49,17 +49,17 @@ func (s *stepDownloadGuestAdditions) Run(state map[string]interface{}) multistep
|
||||||
|
|
||||||
additionsName := fmt.Sprintf("VBoxGuestAdditions_%s.iso", version)
|
additionsName := fmt.Sprintf("VBoxGuestAdditions_%s.iso", version)
|
||||||
|
|
||||||
// Use provided version or get it from virtualbox.org
|
// Use provided version or get it from virtualbox.org
|
||||||
var checksum string
|
var checksum string
|
||||||
|
|
||||||
if config.GuestAdditionsSHA256 != "" {
|
if config.GuestAdditionsSHA256 != "" {
|
||||||
checksum = config.GuestAdditionsSHA256
|
checksum = config.GuestAdditionsSHA256
|
||||||
} else {
|
} else {
|
||||||
checksum, action = s.downloadAdditionsSHA256(state, version, additionsName)
|
checksum, action = s.downloadAdditionsSHA256(state, version, additionsName)
|
||||||
if action != multistep.ActionContinue {
|
if action != multistep.ActionContinue {
|
||||||
return action
|
return action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checksumBytes, err := hex.DecodeString(checksum)
|
checksumBytes, err := hex.DecodeString(checksum)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -67,14 +67,14 @@ func (s *stepDownloadGuestAdditions) Run(state map[string]interface{}) multistep
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the provided source (URL or file path) or generate it
|
// Use the provided source (URL or file path) or generate it
|
||||||
url := config.GuestAdditionsURL
|
url := config.GuestAdditionsURL
|
||||||
if url == "" {
|
if url == "" {
|
||||||
url = fmt.Sprintf(
|
url = fmt.Sprintf(
|
||||||
"http://download.virtualbox.org/virtualbox/%s/%s",
|
"http://download.virtualbox.org/virtualbox/%s/%s",
|
||||||
version,
|
version,
|
||||||
additionsName)
|
additionsName)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Guest additions URL: %s", url)
|
log.Printf("Guest additions URL: %s", url)
|
||||||
|
|
||||||
|
@ -138,12 +138,12 @@ DownloadWaitLoop:
|
||||||
return result, multistep.ActionContinue
|
return result, multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *stepDownloadGuestAdditions) downloadAdditionsSHA256 (state map[string]interface{}, additionsVersion string, additionsName string) (string, multistep.StepAction) {
|
func (s *stepDownloadGuestAdditions) downloadAdditionsSHA256(state map[string]interface{}, additionsVersion string, additionsName string) (string, multistep.StepAction) {
|
||||||
// First things first, we get the list of checksums for the files available
|
// First things first, we get the list of checksums for the files available
|
||||||
// for this version.
|
// for this version.
|
||||||
checksumsUrl := fmt.Sprintf("http://download.virtualbox.org/virtualbox/%s/SHA256SUMS", additionsVersion)
|
checksumsUrl := fmt.Sprintf("http://download.virtualbox.org/virtualbox/%s/SHA256SUMS", additionsVersion)
|
||||||
checksumsFile, err := ioutil.TempFile("", "packer")
|
checksumsFile, err := ioutil.TempFile("", "packer")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state["error"] = fmt.Errorf(
|
state["error"] = fmt.Errorf(
|
||||||
"Failed creating temporary file to store guest addition checksums: %s",
|
"Failed creating temporary file to store guest addition checksums: %s",
|
||||||
|
@ -203,6 +203,6 @@ func (s *stepDownloadGuestAdditions) downloadAdditionsSHA256 (state map[string]i
|
||||||
return "", multistep.ActionHalt
|
return "", multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
return checksum, multistep.ActionContinue
|
return checksum, multistep.ActionContinue
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue