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
6fdcb0f8
Commit
6fdcb0f8
authored
Dec 25, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware/vmx: initial stuff
parent
16911d75
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
142 additions
and
0 deletions
+142
-0
builder/vmware/vmx/builder.go
builder/vmware/vmx/builder.go
+83
-0
builder/vmware/vmx/builder_test.go
builder/vmware/vmx/builder_test.go
+1
-0
builder/vmware/vmx/config.go
builder/vmware/vmx/config.go
+58
-0
No files found.
builder/vmware/vmx/builder.go
0 → 100644
View file @
6fdcb0f8
package
vmx
import
(
"errors"
"fmt"
"github.com/mitchellh/multistep"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
"log"
)
// Builder implements packer.Builder and builds the actual VirtualBox
// images.
type
Builder
struct
{
config
*
Config
runner
multistep
.
Runner
}
// Prepare processes the build configuration parameters.
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
c
,
warnings
,
errs
:=
NewConfig
(
raws
...
)
if
errs
!=
nil
{
return
warnings
,
errs
}
b
.
config
=
c
return
warnings
,
nil
}
// Run executes a Packer build and returns a packer.Artifact representing
// a VirtualBox appliance.
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
driver
,
err
:=
vmwcommon
.
NewDriver
(
&
b
.
config
.
SSHConfig
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed creating VMware driver: %s"
,
err
)
}
// Set up the state.
state
:=
new
(
multistep
.
BasicStateBag
)
state
.
Put
(
"config"
,
b
.
config
)
state
.
Put
(
"driver"
,
driver
)
state
.
Put
(
"hook"
,
hook
)
state
.
Put
(
"ui"
,
ui
)
// Build the steps.
steps
:=
[]
multistep
.
Step
{}
// Run the steps.
if
b
.
config
.
PackerDebug
{
b
.
runner
=
&
multistep
.
DebugRunner
{
Steps
:
steps
,
PauseFn
:
common
.
MultistepDebugFn
(
ui
),
}
}
else
{
b
.
runner
=
&
multistep
.
BasicRunner
{
Steps
:
steps
}
}
b
.
runner
.
Run
(
state
)
// Report any errors.
if
rawErr
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
return
nil
,
rawErr
.
(
error
)
}
// If we were interrupted or cancelled, then just exit.
if
_
,
ok
:=
state
.
GetOk
(
multistep
.
StateCancelled
);
ok
{
return
nil
,
errors
.
New
(
"Build was cancelled."
)
}
if
_
,
ok
:=
state
.
GetOk
(
multistep
.
StateHalted
);
ok
{
return
nil
,
errors
.
New
(
"Build was halted."
)
}
return
nil
,
nil
}
// Cancel.
func
(
b
*
Builder
)
Cancel
()
{
if
b
.
runner
!=
nil
{
log
.
Println
(
"Cancelling the step runner..."
)
b
.
runner
.
Cancel
()
}
}
builder/vmware/vmx/builder_test.go
0 → 100644
View file @
6fdcb0f8
package
vmx
builder/vmware/vmx/config.go
0 → 100644
View file @
6fdcb0f8
package
vmx
import
(
"fmt"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
)
// Config is the configuration structure for the builder.
type
Config
struct
{
common
.
PackerConfig
`mapstructure:",squash"`
vmwcommon
.
SSHConfig
`mapstructure:",squash"`
tpl
*
packer
.
ConfigTemplate
}
func
NewConfig
(
raws
...
interface
{})
(
*
Config
,
[]
string
,
error
)
{
c
:=
new
(
Config
)
md
,
err
:=
common
.
DecodeConfig
(
c
,
raws
...
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
c
.
tpl
,
err
=
packer
.
NewConfigTemplate
()
if
err
!=
nil
{
return
nil
,
nil
,
err
}
c
.
tpl
.
UserVars
=
c
.
PackerUserVars
// Defaults
// Prepare the errors
errs
:=
common
.
CheckUnusedConfig
(
md
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
SSHConfig
.
Prepare
(
c
.
tpl
)
...
)
templates
:=
map
[
string
]
*
string
{}
for
n
,
ptr
:=
range
templates
{
var
err
error
*
ptr
,
err
=
c
.
tpl
.
Process
(
*
ptr
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing %s: %s"
,
n
,
err
))
}
}
// Warnings
var
warnings
[]
string
// Check for any errors.
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
nil
,
warnings
,
errs
}
return
c
,
warnings
,
nil
}
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