Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
e732d861
Commit
e732d861
authored
Sep 05, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: process hdd interface as template, validate
parent
4e2ab039
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletion
+42
-1
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+7
-1
builder/virtualbox/builder_test.go
builder/virtualbox/builder_test.go
+32
-0
builder/virtualbox/step_create_disk.go
builder/virtualbox/step_create_disk.go
+3
-0
No files found.
builder/virtualbox/builder.go
View file @
e732d861
...
...
@@ -32,8 +32,8 @@ type config struct {
GuestAdditionsURL
string
`mapstructure:"guest_additions_url"`
GuestAdditionsSHA256
string
`mapstructure:"guest_additions_sha256"`
GuestOSType
string
`mapstructure:"guest_os_type"`
Headless
bool
`mapstructure:"headless"`
HardDriveInterface
string
`mapstructure:"hard_drive_interface"`
Headless
bool
`mapstructure:"headless"`
HTTPDir
string
`mapstructure:"http_directory"`
HTTPPortMin
uint
`mapstructure:"http_port_min"`
HTTPPortMax
uint
`mapstructure:"http_port_max"`
...
...
@@ -146,6 +146,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
templates
:=
map
[
string
]
*
string
{
"guest_additions_sha256"
:
&
b
.
config
.
GuestAdditionsSHA256
,
"guest_os_type"
:
&
b
.
config
.
GuestOSType
,
"hard_drive_interface"
:
&
b
.
config
.
HardDriveInterface
,
"http_directory"
:
&
b
.
config
.
HTTPDir
,
"iso_checksum"
:
&
b
.
config
.
ISOChecksum
,
"iso_checksum_type"
:
&
b
.
config
.
ISOChecksumType
,
...
...
@@ -214,6 +215,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
errs
,
errors
.
New
(
"invalid format, only 'ovf' or 'ova' are allowed"
))
}
if
b
.
config
.
HardDriveInterface
!=
"ide"
&&
b
.
config
.
HardDriveInterface
!=
"sata"
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"hard_drive_interface can only be ide or sata"
))
}
if
b
.
config
.
HTTPPortMin
>
b
.
config
.
HTTPPortMax
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"http_port_min must be less than http_port_max"
))
...
...
builder/virtualbox/builder_test.go
View file @
e732d861
...
...
@@ -252,6 +252,38 @@ func TestBuilderPrepare_GuestAdditionsURL(t *testing.T) {
}
}
func
TestBuilderPrepare_HardDriveInterface
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
// Test a default boot_wait
delete
(
config
,
"hard_drive_interface"
)
err
:=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
b
.
config
.
HardDriveInterface
!=
"ide"
{
t
.
Fatalf
(
"bad: %s"
,
b
.
config
.
HardDriveInterface
)
}
// Test with a bad
config
[
"hard_drive_interface"
]
=
"fake"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
// Test with a good
config
[
"hard_drive_interface"
]
=
"sata"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
}
func
TestBuilderPrepare_HTTPPort
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
...
...
builder/virtualbox/step_create_disk.go
View file @
e732d861
...
...
@@ -51,6 +51,9 @@ func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
}
// Add a SATA controller if we were asked to use SATA. We still attach
// the IDE controller above because some other things (disks) require
// that.
if
config
.
HardDriveInterface
==
"sata"
{
controllerName
=
"SATA Controller"
command
=
[]
string
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment