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
40c169f7
Commit
40c169f7
authored
Sep 02, 2014
by
Mikhail Zholobov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/parallels: Added 'StepPrepareParallelsTools'
parent
13b355ea
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
170 additions
and
0 deletions
+170
-0
builder/parallels/common/step_prepare_parallels_tools.go
builder/parallels/common/step_prepare_parallels_tools.go
+47
-0
builder/parallels/common/step_prepare_parallels_tools_test.go
...der/parallels/common/step_prepare_parallels_tools_test.go
+115
-0
builder/parallels/iso/builder.go
builder/parallels/iso/builder.go
+4
-0
builder/parallels/pvm/builder.go
builder/parallels/pvm/builder.go
+4
-0
No files found.
builder/parallels/common/step_prepare_parallels_tools.go
0 → 100644
View file @
40c169f7
package
common
import
(
"fmt"
"github.com/mitchellh/multistep"
"os"
)
// This step prepares parameters related to Parallels Tools.
//
// Uses:
// driver Driver
//
// Produces:
// parallels_tools_path string
type
StepPrepareParallelsTools
struct
{
ParallelsToolsFlavor
string
ParallelsToolsMode
string
}
func
(
s
*
StepPrepareParallelsTools
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
driver
:=
state
.
Get
(
"driver"
)
.
(
Driver
)
if
s
.
ParallelsToolsMode
==
ParallelsToolsModeDisable
{
return
multistep
.
ActionContinue
}
path
,
err
:=
driver
.
ToolsIsoPath
(
s
.
ParallelsToolsFlavor
)
if
err
!=
nil
{
state
.
Put
(
"error"
,
err
)
return
multistep
.
ActionHalt
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Couldn't find Parallels Tools for the '%s' flavor! Please, check the
\n
"
+
"value of 'parallels_tools_flavor'. Valid flavors are: 'win', 'lin',
\n
"
+
"'mac', 'os2' and 'other'"
,
s
.
ParallelsToolsFlavor
))
return
multistep
.
ActionHalt
}
state
.
Put
(
"parallels_tools_path"
,
path
)
return
multistep
.
ActionContinue
}
func
(
s
*
StepPrepareParallelsTools
)
Cleanup
(
multistep
.
StateBag
)
{}
builder/parallels/common/step_prepare_parallels_tools_test.go
0 → 100644
View file @
40c169f7
package
common
import
(
"io/ioutil"
"os"
"testing"
"github.com/mitchellh/multistep"
)
func
TestStepPrepareParallelsTools_impl
(
t
*
testing
.
T
)
{
var
_
multistep
.
Step
=
new
(
StepPrepareParallelsTools
)
}
func
TestStepPrepareParallelsTools
(
t
*
testing
.
T
)
{
tf
,
err
:=
ioutil
.
TempFile
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
tf
.
Close
()
defer
os
.
Remove
(
tf
.
Name
())
state
:=
testState
(
t
)
step
:=
&
StepPrepareParallelsTools
{
ParallelsToolsMode
:
""
,
ParallelsToolsFlavor
:
"foo"
,
}
driver
:=
state
.
Get
(
"driver"
)
.
(
*
DriverMock
)
// Mock results
driver
.
ToolsIsoPathResult
=
tf
.
Name
()
// 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
.
ToolsIsoPathCalled
{
t
.
Fatal
(
"tools iso path should be called"
)
}
if
driver
.
ToolsIsoPathFlavor
!=
"foo"
{
t
.
Fatalf
(
"bad: %#v"
,
driver
.
ToolsIsoPathFlavor
)
}
// Test the resulting state
path
,
ok
:=
state
.
GetOk
(
"parallels_tools_path"
)
if
!
ok
{
t
.
Fatal
(
"should have parallels_tools_path"
)
}
if
path
!=
tf
.
Name
()
{
t
.
Fatalf
(
"bad: %#v"
,
path
)
}
}
func
TestStepPrepareParallelsTools_disabled
(
t
*
testing
.
T
)
{
state
:=
testState
(
t
)
step
:=
&
StepPrepareParallelsTools
{
ParallelsToolsFlavor
:
"foo"
,
ParallelsToolsMode
:
ParallelsToolsModeDisable
,
}
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
.
ToolsIsoPathCalled
{
t
.
Fatal
(
"tools iso path should NOT be called"
)
}
}
func
TestStepPrepareParallelsTools_nonExist
(
t
*
testing
.
T
)
{
state
:=
testState
(
t
)
step
:=
&
StepPrepareParallelsTools
{
ParallelsToolsFlavor
:
"foo"
,
ParallelsToolsMode
:
""
,
}
driver
:=
state
.
Get
(
"driver"
)
.
(
*
DriverMock
)
// Mock results
driver
.
ToolsIsoPathResult
=
"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"
)
}
// Test the driver
if
!
driver
.
ToolsIsoPathCalled
{
t
.
Fatal
(
"tools iso path should be called"
)
}
if
driver
.
ToolsIsoPathFlavor
!=
"foo"
{
t
.
Fatalf
(
"bad: %#v"
,
driver
.
ToolsIsoPathFlavor
)
}
// Test the resulting state
if
_
,
ok
:=
state
.
GetOk
(
"parallels_tools_path"
);
ok
{
t
.
Fatal
(
"should NOT have parallels_tools_path"
)
}
}
builder/parallels/iso/builder.go
View file @
40c169f7
...
...
@@ -225,6 +225,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
}
steps
:=
[]
multistep
.
Step
{
&
parallelscommon
.
StepPrepareParallelsTools
{
ParallelsToolsFlavor
:
b
.
config
.
ParallelsToolsFlavor
,
ParallelsToolsMode
:
b
.
config
.
ParallelsToolsMode
,
},
&
common
.
StepDownload
{
Checksum
:
b
.
config
.
ISOChecksum
,
ChecksumType
:
b
.
config
.
ISOChecksumType
,
...
...
builder/parallels/pvm/builder.go
View file @
40c169f7
...
...
@@ -47,6 +47,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
// Build the steps.
steps
:=
[]
multistep
.
Step
{
&
parallelscommon
.
StepPrepareParallelsTools
{
ParallelsToolsMode
:
b
.
config
.
ParallelsToolsMode
,
ParallelsToolsFlavor
:
b
.
config
.
ParallelsToolsFlavor
,
},
&
parallelscommon
.
StepOutputDir
{
Force
:
b
.
config
.
PackerForce
,
Path
:
b
.
config
.
OutputDir
,
...
...
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