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
fbd20dff
Commit
fbd20dff
authored
Dec 22, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox/common: StepRemoveDevices
parent
b65559d8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
8 deletions
+74
-8
builder/virtualbox/common/step_remove_devices.go
builder/virtualbox/common/step_remove_devices.go
+8
-6
builder/virtualbox/common/step_remove_devices_test.go
builder/virtualbox/common/step_remove_devices_test.go
+64
-0
builder/virtualbox/iso/builder.go
builder/virtualbox/iso/builder.go
+1
-1
builder/virtualbox/ovf/builder.go
builder/virtualbox/ovf/builder.go
+1
-1
No files found.
builder/virtualbox/
iso
/step_remove_devices.go
→
builder/virtualbox/
common
/step_remove_devices.go
View file @
fbd20dff
package
iso
package
common
import
(
"fmt"
"github.com/mitchellh/multistep"
vboxcommon
"github.com/mitchellh/packer/builder/virtualbox/common"
"github.com/mitchellh/packer/packer"
)
...
...
@@ -11,12 +10,15 @@ import (
// machine that we may have added.
//
// Uses:
// driver Driver
// ui packer.Ui
// vmName string
//
// Produces:
type
s
tepRemoveDevices
struct
{}
type
S
tepRemoveDevices
struct
{}
func
(
s
*
s
tepRemoveDevices
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
driver
:=
state
.
Get
(
"driver"
)
.
(
vboxcommon
.
Driver
)
func
(
s
*
S
tepRemoveDevices
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
...
...
@@ -56,5 +58,5 @@ func (s *stepRemoveDevices) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionContinue
}
func
(
s
*
s
tepRemoveDevices
)
Cleanup
(
state
multistep
.
StateBag
)
{
func
(
s
*
S
tepRemoveDevices
)
Cleanup
(
state
multistep
.
StateBag
)
{
}
builder/virtualbox/common/step_remove_devices_test.go
0 → 100644
View file @
fbd20dff
package
common
import
(
"github.com/mitchellh/multistep"
"testing"
)
func
TestStepRemoveDevices_impl
(
t
*
testing
.
T
)
{
var
_
multistep
.
Step
=
new
(
StepRemoveDevices
)
}
func
TestStepRemoveDevices
(
t
*
testing
.
T
)
{
state
:=
testState
(
t
)
step
:=
new
(
StepRemoveDevices
)
state
.
Put
(
"vmName"
,
"foo"
)
driver
:=
state
.
Get
(
"driver"
)
.
(
*
DriverMock
)
// Test the run
if
action
:=
step
.
Run
(
state
);
action
!=
multistep
.
ActionContinue
{
t
.
Fatalf
(
"bad action: %#v"
,
action
)
}
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
t
.
Fatal
(
"should NOT have error"
)
}
// Test that ISO was removed
if
len
(
driver
.
VBoxManageCalls
)
!=
1
{
t
.
Fatalf
(
"bad: %#v"
,
driver
.
VBoxManageCalls
)
}
if
driver
.
VBoxManageCalls
[
0
][
3
]
!=
"IDE Controller"
{
t
.
Fatalf
(
"bad: %#v"
,
driver
.
VBoxManageCalls
)
}
}
func
TestStepRemoveDevices_floppyPath
(
t
*
testing
.
T
)
{
state
:=
testState
(
t
)
step
:=
new
(
StepRemoveDevices
)
state
.
Put
(
"floppy_path"
,
"foo"
)
state
.
Put
(
"vmName"
,
"foo"
)
driver
:=
state
.
Get
(
"driver"
)
.
(
*
DriverMock
)
// Test the run
if
action
:=
step
.
Run
(
state
);
action
!=
multistep
.
ActionContinue
{
t
.
Fatalf
(
"bad action: %#v"
,
action
)
}
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
t
.
Fatal
(
"should NOT have error"
)
}
// Test that both were removed
if
len
(
driver
.
VBoxManageCalls
)
!=
2
{
t
.
Fatalf
(
"bad: %#v"
,
driver
.
VBoxManageCalls
)
}
if
driver
.
VBoxManageCalls
[
0
][
3
]
!=
"Floppy Controller"
{
t
.
Fatalf
(
"bad: %#v"
,
driver
.
VBoxManageCalls
)
}
if
driver
.
VBoxManageCalls
[
1
][
3
]
!=
"IDE Controller"
{
t
.
Fatalf
(
"bad: %#v"
,
driver
.
VBoxManageCalls
)
}
}
builder/virtualbox/iso/builder.go
View file @
fbd20dff
...
...
@@ -326,7 +326,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Command
:
b
.
config
.
ShutdownCommand
,
Timeout
:
b
.
config
.
ShutdownTimeout
,
},
new
(
s
tepRemoveDevices
),
new
(
vboxcommon
.
S
tepRemoveDevices
),
new
(
stepExport
),
}
...
...
builder/virtualbox/ovf/builder.go
View file @
fbd20dff
...
...
@@ -79,8 +79,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Command
:
b
.
config
.
ShutdownCommand
,
Timeout
:
b
.
config
.
ShutdownTimeout
,
},
new
(
vboxcommon
.
StepRemoveDevices
),
/*
new(stepRemoveDevices),
new(stepExport),
*/
}
...
...
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