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
cfcbfa39
Commit
cfcbfa39
authored
Aug 19, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #309 from jsiebens/virtualbox_ova
builder/virtualbox: export to ovf or ova (default ovf)
parents
a329d7dd
a19bd564
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
1 deletion
+44
-1
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+11
-0
builder/virtualbox/builder_test.go
builder/virtualbox/builder_test.go
+32
-0
builder/virtualbox/step_export.go
builder/virtualbox/step_export.go
+1
-1
No files found.
builder/virtualbox/builder.go
View file @
cfcbfa39
...
...
@@ -48,6 +48,7 @@ type config struct {
VBoxVersionFile
string
`mapstructure:"virtualbox_version_file"`
VBoxManage
[][]
string
`mapstructure:"vboxmanage"`
VMName
string
`mapstructure:"vm_name"`
Format
string
`mapstructure:"format"`
RawBootWait
string
`mapstructure:"boot_wait"`
RawSingleISOUrl
string
`mapstructure:"iso_url"`
...
...
@@ -131,6 +132,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
b
.
config
.
VMName
=
fmt
.
Sprintf
(
"packer-%s"
,
b
.
config
.
PackerBuildName
)
}
if
b
.
config
.
Format
==
""
{
b
.
config
.
Format
=
"ovf"
}
// Errors
templates
:=
map
[
string
]
*
string
{
"guest_additions_sha256"
:
&
b
.
config
.
GuestAdditionsSHA256
,
...
...
@@ -145,6 +150,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
"ssh_username"
:
&
b
.
config
.
SSHUser
,
"virtualbox_version_file"
:
&
b
.
config
.
VBoxVersionFile
,
"vm_name"
:
&
b
.
config
.
VMName
,
"format"
:
&
b
.
config
.
Format
,
"boot_wait"
:
&
b
.
config
.
RawBootWait
,
"shutdown_timeout"
:
&
b
.
config
.
RawShutdownTimeout
,
"ssh_wait_timeout"
:
&
b
.
config
.
RawSSHWaitTimeout
,
...
...
@@ -197,6 +203,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
}
if
!
(
b
.
config
.
Format
==
"ovf"
||
b
.
config
.
Format
==
"ova"
)
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"invalid format, only 'ovf' or 'ova' are allowed"
))
}
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 @
cfcbfa39
...
...
@@ -58,6 +58,10 @@ func TestBuilderPrepare_Defaults(t *testing.T) {
if
b
.
config
.
VMName
!=
"packer-foo"
{
t
.
Errorf
(
"bad vm name: %s"
,
b
.
config
.
VMName
)
}
if
b
.
config
.
Format
!=
"ovf"
{
t
.
Errorf
(
"bad format: %s"
,
b
.
config
.
Format
)
}
}
func
TestBuilderPrepare_BootWait
(
t
*
testing
.
T
)
{
...
...
@@ -248,6 +252,34 @@ func TestBuilderPrepare_HTTPPort(t *testing.T) {
}
}
func
TestBuilderPrepare_Format
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
// Bad
config
[
"format"
]
=
"illegal value"
err
:=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
// Good
config
[
"format"
]
=
"ova"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
// Good
config
[
"format"
]
=
"ovf"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
}
func
TestBuilderPrepare_InvalidKey
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
...
...
builder/virtualbox/step_export.go
View file @
cfcbfa39
...
...
@@ -50,7 +50,7 @@ func (s *stepExport) Run(state map[string]interface{}) multistep.StepAction {
}
// Export the VM to an OVF
outputPath
:=
filepath
.
Join
(
config
.
OutputDir
,
"packer.
ovf"
)
outputPath
:=
filepath
.
Join
(
config
.
OutputDir
,
"packer.
"
+
config
.
Format
)
command
=
[]
string
{
"export"
,
...
...
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