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
0dc42268
Commit
0dc42268
authored
May 27, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox/ovf: new interpolation
parent
d15bc904
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
77 deletions
+33
-77
builder/virtualbox/ovf/builder.go
builder/virtualbox/ovf/builder.go
+5
-5
builder/virtualbox/ovf/config.go
builder/virtualbox/ovf/config.go
+28
-72
No files found.
builder/virtualbox/ovf/builder.go
View file @
0dc42268
...
...
@@ -70,7 +70,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
GuestAdditionsMode
:
b
.
config
.
GuestAdditionsMode
,
GuestAdditionsURL
:
b
.
config
.
GuestAdditionsURL
,
GuestAdditionsSHA256
:
b
.
config
.
GuestAdditionsSHA256
,
Tpl
:
b
.
config
.
tpl
,
Ctx
:
b
.
config
.
ctx
,
},
&
StepImport
{
Name
:
b
.
config
.
VMName
,
...
...
@@ -88,7 +88,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
},
&
vboxcommon
.
StepVBoxManage
{
Commands
:
b
.
config
.
VBoxManage
,
Tpl
:
b
.
config
.
tpl
,
Ctx
:
b
.
config
.
ctx
,
},
&
vboxcommon
.
StepRun
{
BootWait
:
b
.
config
.
BootWait
,
...
...
@@ -97,7 +97,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
vboxcommon
.
StepTypeBootCommand
{
BootCommand
:
b
.
config
.
BootCommand
,
VMName
:
b
.
config
.
VMName
,
Tpl
:
b
.
config
.
tpl
,
Ctx
:
b
.
config
.
ctx
,
},
&
common
.
StepConnectSSH
{
SSHAddress
:
vboxcommon
.
SSHAddress
,
...
...
@@ -110,7 +110,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
vboxcommon
.
StepUploadGuestAdditions
{
GuestAdditionsMode
:
b
.
config
.
GuestAdditionsMode
,
GuestAdditionsPath
:
b
.
config
.
GuestAdditionsPath
,
Tpl
:
b
.
config
.
tpl
,
Ctx
:
b
.
config
.
ctx
,
},
new
(
common
.
StepProvision
),
&
vboxcommon
.
StepShutdown
{
...
...
@@ -120,7 +120,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
new
(
vboxcommon
.
StepRemoveDevices
),
&
vboxcommon
.
StepVBoxManage
{
Commands
:
b
.
config
.
VBoxManagePost
,
Tpl
:
b
.
config
.
tpl
,
Ctx
:
b
.
config
.
ctx
,
},
&
vboxcommon
.
StepExport
{
Format
:
b
.
config
.
Format
,
...
...
builder/virtualbox/ovf/config.go
View file @
0dc42268
...
...
@@ -7,7 +7,9 @@ import (
vboxcommon
"github.com/mitchellh/packer/builder/virtualbox/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
)
// Config is the configuration structure for the builder.
...
...
@@ -34,22 +36,27 @@ type Config struct {
ImportOpts
string
`mapstructure:"import_opts"`
ImportFlags
[]
string
`mapstructure:"import_flags"`
tpl
*
packer
.
ConfigTemplate
ctx
interpolate
.
Context
}
func
NewConfig
(
raws
...
interface
{})
(
*
Config
,
[]
string
,
error
)
{
c
:=
new
(
Config
)
md
,
err
:=
common
.
DecodeConfig
(
c
,
raws
...
)
var
c
Config
err
:=
config
.
Decode
(
&
c
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"boot_command"
,
"guest_additions_path"
,
"guest_additions_url"
,
"vboxmanage"
,
"vboxmanage_post"
,
},
},
},
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
if
c
.
GuestAdditionsMode
==
""
{
c
.
GuestAdditionsMode
=
"upload"
...
...
@@ -63,49 +70,17 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
// Prepare the errors
errs
:=
common
.
CheckUnusedConfig
(
md
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
ExportConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
ExportOpts
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
FloppyConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
OutputConfig
.
Prepare
(
c
.
tpl
,
&
c
.
PackerConfig
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
RunConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
ShutdownConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
SSHConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
VBoxManageConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
VBoxManagePostConfig
.
Prepare
(
c
.
tpl
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
VBoxVersionConfig
.
Prepare
(
c
.
tpl
)
...
)
templates
:=
map
[
string
]
*
string
{
"guest_additions_mode"
:
&
c
.
GuestAdditionsMode
,
"guest_additions_sha256"
:
&
c
.
GuestAdditionsSHA256
,
"source_path"
:
&
c
.
SourcePath
,
"vm_name"
:
&
c
.
VMName
,
"import_opts"
:
&
c
.
ImportOpts
,
}
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
))
}
}
sliceTemplates
:=
map
[
string
][]
string
{
"import_flags"
:
c
.
ImportFlags
,
}
for
n
,
slice
:=
range
sliceTemplates
{
for
i
,
elem
:=
range
slice
{
var
err
error
slice
[
i
],
err
=
c
.
tpl
.
Process
(
elem
,
nil
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing %s[%d]: %s"
,
n
,
i
,
err
))
}
}
}
var
errs
*
packer
.
MultiError
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
ExportConfig
.
Prepare
(
&
c
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
ExportOpts
.
Prepare
(
&
c
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
FloppyConfig
.
Prepare
(
&
c
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
OutputConfig
.
Prepare
(
&
c
.
ctx
,
&
c
.
PackerConfig
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
RunConfig
.
Prepare
(
&
c
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
ShutdownConfig
.
Prepare
(
&
c
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
SSHConfig
.
Prepare
(
&
c
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
VBoxManageConfig
.
Prepare
(
&
c
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
VBoxManagePostConfig
.
Prepare
(
&
c
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
c
.
VBoxVersionConfig
.
Prepare
(
&
c
.
ctx
)
...
)
if
c
.
SourcePath
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"source_path is required"
))
...
...
@@ -116,25 +91,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
}
for
i
,
command
:=
range
c
.
BootCommand
{
if
err
:=
c
.
tpl
.
Validate
(
command
);
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error processing boot_command[%d]: %s"
,
i
,
err
))
}
}
validates
:=
map
[
string
]
*
string
{
"guest_additions_path"
:
&
c
.
GuestAdditionsPath
,
"guest_additions_url"
:
&
c
.
GuestAdditionsURL
,
}
for
n
,
ptr
:=
range
validates
{
if
err
:=
c
.
tpl
.
Validate
(
*
ptr
);
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Error parsing %s: %s"
,
n
,
err
))
}
}
validMode
:=
false
validModes
:=
[]
string
{
vboxcommon
.
GuestAdditionsModeDisable
,
...
...
@@ -176,5 +132,5 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c
.
ImportFlags
=
append
(
c
.
ImportFlags
,
"--options"
,
c
.
ImportOpts
)
}
return
c
,
warnings
,
nil
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