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
886c0d3a
Commit
886c0d3a
authored
Dec 21, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox/common: StepSuppressMessages
parent
db167c5a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
128 additions
and
8 deletions
+128
-8
builder/virtualbox/common/driver_mock.go
builder/virtualbox/common/driver_mock.go
+65
-0
builder/virtualbox/common/step_suppress_messages.go
builder/virtualbox/common/step_suppress_messages.go
+5
-6
builder/virtualbox/common/step_suppress_messages_test.go
builder/virtualbox/common/step_suppress_messages_test.go
+50
-0
builder/virtualbox/common/step_test.go
builder/virtualbox/common/step_test.go
+1
-0
builder/virtualbox/iso/builder.go
builder/virtualbox/iso/builder.go
+1
-1
builder/virtualbox/ovf/builder.go
builder/virtualbox/ovf/builder.go
+6
-1
No files found.
builder/virtualbox/common/driver_mock.go
0 → 100644
View file @
886c0d3a
package
common
type
DriverMock
struct
{
CreateSATAControllerVM
string
CreateSATAControllerController
string
CreateSATAControllerErr
error
IsRunningName
string
IsRunningReturn
bool
IsRunningErr
error
StopName
string
StopErr
error
SuppressMessagesCalled
bool
SuppressMessagesErr
error
VBoxManageCalled
bool
VBoxManageArgs
[]
string
VBoxManageErr
error
VerifyCalled
bool
VerifyErr
error
VersionCalled
bool
VersionResult
string
VersionErr
error
}
func
(
d
*
DriverMock
)
CreateSATAController
(
vm
string
,
controller
string
)
error
{
d
.
CreateSATAControllerVM
=
vm
d
.
CreateSATAControllerController
=
vm
return
d
.
CreateSATAControllerErr
}
func
(
d
*
DriverMock
)
IsRunning
(
name
string
)
(
bool
,
error
)
{
d
.
IsRunningName
=
name
return
d
.
IsRunningReturn
,
d
.
IsRunningErr
}
func
(
d
*
DriverMock
)
Stop
(
name
string
)
error
{
d
.
StopName
=
name
return
d
.
StopErr
}
func
(
d
*
DriverMock
)
SuppressMessages
()
error
{
d
.
SuppressMessagesCalled
=
true
return
d
.
SuppressMessagesErr
}
func
(
d
*
DriverMock
)
VBoxManage
(
args
...
string
)
error
{
d
.
VBoxManageCalled
=
true
d
.
VBoxManageArgs
=
args
return
d
.
VBoxManageErr
}
func
(
d
*
DriverMock
)
Verify
()
error
{
d
.
VerifyCalled
=
true
return
d
.
VerifyErr
}
func
(
d
*
DriverMock
)
Version
()
(
string
,
error
)
{
d
.
VersionCalled
=
true
return
d
.
VersionResult
,
d
.
VersionErr
}
builder/virtualbox/
iso
/step_suppress_messages.go
→
builder/virtualbox/
common
/step_suppress_messages.go
View file @
886c0d3a
package
iso
package
common
import
(
import
(
"fmt"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
vboxcommon
"github.com/mitchellh/packer/builder/virtualbox/common"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
"log"
"log"
)
)
// This step sets some variables in VirtualBox so that annoying
// This step sets some variables in VirtualBox so that annoying
// pop-up messages don't exist.
// pop-up messages don't exist.
type
s
tepSuppressMessages
struct
{}
type
S
tepSuppressMessages
struct
{}
func
(
s
tepSuppressMessages
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
S
tepSuppressMessages
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
driver
:=
state
.
Get
(
"driver"
)
.
(
vboxcommon
.
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
log
.
Println
(
"Suppressing annoying messages in VirtualBox"
)
log
.
Println
(
"Suppressing annoying messages in VirtualBox"
)
...
@@ -27,4 +26,4 @@ func (stepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -27,4 +26,4 @@ func (stepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
s
tepSuppressMessages
)
Cleanup
(
multistep
.
StateBag
)
{}
func
(
S
tepSuppressMessages
)
Cleanup
(
multistep
.
StateBag
)
{}
builder/virtualbox/common/step_suppress_messages_test.go
0 → 100644
View file @
886c0d3a
package
common
import
(
"errors"
"github.com/mitchellh/multistep"
"testing"
)
func
TestStepSuppressMessages_impl
(
t
*
testing
.
T
)
{
var
_
multistep
.
Step
=
new
(
StepSuppressMessages
)
}
func
TestStepSuppressMessages
(
t
*
testing
.
T
)
{
state
:=
testState
(
t
)
step
:=
new
(
StepSuppressMessages
)
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"
)
}
if
!
driver
.
SuppressMessagesCalled
{
t
.
Fatal
(
"should call suppressmessages"
)
}
}
func
TestStepSuppressMessages_error
(
t
*
testing
.
T
)
{
state
:=
testState
(
t
)
step
:=
new
(
StepSuppressMessages
)
driver
:=
state
.
Get
(
"driver"
)
.
(
*
DriverMock
)
driver
.
SuppressMessagesErr
=
errors
.
New
(
"foo"
)
// Test the run
if
action
:=
step
.
Run
(
state
);
action
!=
multistep
.
ActionHalt
{
t
.
Fatalf
(
"bad action: %#v"
,
action
)
}
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
!
ok
{
t
.
Fatal
(
"should have error"
)
}
if
!
driver
.
SuppressMessagesCalled
{
t
.
Fatal
(
"should call suppressmessages"
)
}
}
builder/virtualbox/common/step_test.go
View file @
886c0d3a
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
func
testState
(
t
*
testing
.
T
)
multistep
.
StateBag
{
func
testState
(
t
*
testing
.
T
)
multistep
.
StateBag
{
state
:=
new
(
multistep
.
BasicStateBag
)
state
:=
new
(
multistep
.
BasicStateBag
)
state
.
Put
(
"driver"
,
new
(
DriverMock
))
state
.
Put
(
"ui"
,
&
packer
.
BasicUi
{
state
.
Put
(
"ui"
,
&
packer
.
BasicUi
{
Reader
:
new
(
bytes
.
Buffer
),
Reader
:
new
(
bytes
.
Buffer
),
Writer
:
new
(
bytes
.
Buffer
),
Writer
:
new
(
bytes
.
Buffer
),
...
...
builder/virtualbox/iso/builder.go
View file @
886c0d3a
...
@@ -401,7 +401,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -401,7 +401,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Files
:
b
.
config
.
FloppyFiles
,
Files
:
b
.
config
.
FloppyFiles
,
},
},
new
(
stepHTTPServer
),
new
(
stepHTTPServer
),
new
(
s
tepSuppressMessages
),
new
(
vboxcommon
.
S
tepSuppressMessages
),
new
(
stepCreateVM
),
new
(
stepCreateVM
),
new
(
stepCreateDisk
),
new
(
stepCreateDisk
),
new
(
stepAttachISO
),
new
(
stepAttachISO
),
...
...
builder/virtualbox/ovf/builder.go
View file @
886c0d3a
...
@@ -37,7 +37,12 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -37,7 +37,12 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
new(stepDownloadGuestAdditions),
new(stepDownloadGuestAdditions),
*/
*/
/*
/*
new(stepPrepareOutputDir),
&vboxcommon.StepOutputDir{
Force: b.config.PackerForce,
Path: b.config.OutputDir,
},
*/
/*
&common.StepCreateFloppy{
&common.StepCreateFloppy{
Files: b.config.FloppyFiles,
Files: b.config.FloppyFiles,
},
},
...
...
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