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
4d351eda
Commit
4d351eda
authored
Jun 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: improved validation
parent
24895069
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+4
-0
builder/virtualbox/builder_test.go
builder/virtualbox/builder_test.go
+29
-0
No files found.
builder/virtualbox/builder.go
View file @
4d351eda
...
...
@@ -109,6 +109,10 @@ func (b *Builder) Prepare(raw interface{}) error {
}
}
if
b
.
config
.
SSHHostPortMin
>
b
.
config
.
SSHHostPortMax
{
errs
=
append
(
errs
,
errors
.
New
(
"ssh_host_port_min must be less than ssh_host_port_max"
))
}
b
.
driver
,
err
=
b
.
newDriver
()
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Failed creating VirtualBox driver: %s"
,
err
))
...
...
builder/virtualbox/builder_test.go
View file @
4d351eda
...
...
@@ -122,3 +122,32 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
t
.
Fatalf
(
"iso_url should be modified: %s"
,
b
.
config
.
ISOUrl
)
}
}
func
TestBuilderPrepare_SSHHostPort
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
// Bad
config
[
"ssh_host_port_min"
]
=
1000
config
[
"ssh_host_port_max"
]
=
500
err
:=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
// Bad
config
[
"ssh_host_port_min"
]
=
-
500
err
=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
// Good
config
[
"ssh_host_port_min"
]
=
500
config
[
"ssh_host_port_max"
]
=
1000
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
}
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