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
87ab914a
Commit
87ab914a
authored
Dec 24, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: StepCompactDisk
parent
f01b21c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
10 deletions
+70
-10
builder/vmware/common/step_compact_disk.go
builder/vmware/common/step_compact_disk.go
+8
-9
builder/vmware/common/step_compact_disk_test.go
builder/vmware/common/step_compact_disk_test.go
+59
-0
builder/vmware/iso/builder.go
builder/vmware/iso/builder.go
+3
-1
No files found.
builder/vmware/
iso
/step_compact_disk.go
→
builder/vmware/
common
/step_compact_disk.go
View file @
87ab914a
package
iso
package
common
import
(
import
(
"fmt"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
"log"
"log"
)
)
...
@@ -12,22 +11,22 @@ import (
...
@@ -12,22 +11,22 @@ import (
// boolean is true.
// boolean is true.
//
//
// Uses:
// Uses:
// config *config
// driver Driver
// driver Driver
// full_disk_path string
// full_disk_path string
// ui packer.Ui
// ui packer.Ui
//
//
// Produces:
// Produces:
// <nothing>
// <nothing>
type
stepCompactDisk
struct
{}
type
StepCompactDisk
struct
{
Skip
bool
}
func
(
stepCompactDisk
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
func
(
s
StepCompactDisk
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
config
:=
state
.
Get
(
"config"
)
.
(
*
config
)
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
full_disk_path
:=
state
.
Get
(
"full_disk_path"
)
.
(
string
)
full_disk_path
:=
state
.
Get
(
"full_disk_path"
)
.
(
string
)
if
config
.
SkipCompaction
==
true
{
if
s
.
Skip
{
log
.
Println
(
"Skipping disk compaction step..."
)
log
.
Println
(
"Skipping disk compaction step..."
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
...
@@ -41,4 +40,4 @@ func (stepCompactDisk) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -41,4 +40,4 @@ func (stepCompactDisk) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
func
(
s
tepCompactDisk
)
Cleanup
(
multistep
.
StateBag
)
{}
func
(
S
tepCompactDisk
)
Cleanup
(
multistep
.
StateBag
)
{}
builder/vmware/common/step_compact_disk_test.go
0 → 100644
View file @
87ab914a
package
common
import
(
"testing"
"github.com/mitchellh/multistep"
)
func
TestStepCompactDisk_impl
(
t
*
testing
.
T
)
{
var
_
multistep
.
Step
=
new
(
StepCompactDisk
)
}
func
TestStepCompactDisk
(
t
*
testing
.
T
)
{
state
:=
testState
(
t
)
step
:=
new
(
StepCompactDisk
)
state
.
Put
(
"full_disk_path"
,
"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 the driver
if
!
driver
.
CompactDiskCalled
{
t
.
Fatal
(
"should've called"
)
}
if
driver
.
CompactDiskPath
!=
"foo"
{
t
.
Fatal
(
"should call with right path"
)
}
}
func
TestStepCompactDisk_skip
(
t
*
testing
.
T
)
{
state
:=
testState
(
t
)
step
:=
new
(
StepCompactDisk
)
step
.
Skip
=
true
state
.
Put
(
"full_disk_path"
,
"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 the driver
if
driver
.
CompactDiskCalled
{
t
.
Fatal
(
"should not have called"
)
}
}
builder/vmware/iso/builder.go
View file @
87ab914a
...
@@ -413,7 +413,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -413,7 +413,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
stepShutdown
{},
&
stepShutdown
{},
&
vmwcommon
.
StepCleanFiles
{},
&
vmwcommon
.
StepCleanFiles
{},
&
vmwcommon
.
StepCleanVMX
{},
&
vmwcommon
.
StepCleanVMX
{},
&
stepCompactDisk
{},
&
vmwcommon
.
StepCompactDisk
{
Skip
:
b
.
config
.
SkipCompaction
,
},
}
}
// Run!
// Run!
...
...
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