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
72741dbe
Commit
72741dbe
authored
Jun 23, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox: Ability to set DiskSize
parent
ffd12193
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletion
+33
-1
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+5
-0
builder/virtualbox/builder_test.go
builder/virtualbox/builder_test.go
+26
-0
builder/virtualbox/step_create_disk.go
builder/virtualbox/step_create_disk.go
+2
-1
No files found.
builder/virtualbox/builder.go
View file @
72741dbe
...
...
@@ -27,6 +27,7 @@ type Builder struct {
type
config
struct
{
BootCommand
[]
string
`mapstructure:"boot_command"`
BootWait
time
.
Duration
``
DiskSize
uint
`mapstructure:"disk_size"`
GuestOSType
string
`mapstructure:"guest_os_type"`
HTTPDir
string
`mapstructure:"http_directory"`
HTTPPortMin
uint
`mapstructure:"http_port_min"`
...
...
@@ -61,6 +62,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
}
if
b
.
config
.
DiskSize
==
0
{
b
.
config
.
DiskSize
=
40000
}
if
b
.
config
.
GuestOSType
==
""
{
b
.
config
.
GuestOSType
=
"Other"
}
...
...
builder/virtualbox/builder_test.go
View file @
72741dbe
...
...
@@ -75,6 +75,32 @@ func TestBuilderPrepare_BootWait(t *testing.T) {
}
}
func
TestBuilderPrepare_DiskSize
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
delete
(
config
,
"disk_size"
)
err
:=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"bad err: %s"
,
err
)
}
if
b
.
config
.
DiskSize
!=
40000
{
t
.
Fatalf
(
"bad size: %d"
,
b
.
config
.
DiskSize
)
}
config
[
"disk_size"
]
=
60000
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
DiskSize
!=
60000
{
t
.
Fatalf
(
"bad size: %s"
,
b
.
config
.
DiskSize
)
}
}
func
TestBuilderPrepare_HTTPPort
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
...
...
builder/virtualbox/step_create_disk.go
View file @
72741dbe
...
...
@@ -5,6 +5,7 @@ import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"path/filepath"
"strconv"
"strings"
)
...
...
@@ -24,7 +25,7 @@ func (s *stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction
command
:=
[]
string
{
"createhd"
,
"--filename"
,
path
,
"--size"
,
"40000"
,
"--size"
,
strconv
.
FormatUint
(
uint64
(
config
.
DiskSize
),
10
)
,
"--format"
,
format
,
"--variant"
,
"Standard"
,
}
...
...
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