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
84189f7a
Commit
84189f7a
authored
Jun 22, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/*: properly save interpolation context
parent
d6004564
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
48 additions
and
38 deletions
+48
-38
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+6
-6
builder/amazon/chroot/step_mount_device.go
builder/amazon/chroot/step_mount_device.go
+1
-1
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+7
-7
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+7
-7
builder/amazon/instance/step_bundle_volume.go
builder/amazon/instance/step_bundle_volume.go
+1
-1
builder/amazon/instance/step_upload_bundle.go
builder/amazon/instance/step_upload_bundle.go
+1
-1
builder/digitalocean/config.go
builder/digitalocean/config.go
+5
-4
builder/docker/config.go
builder/docker/config.go
+3
-2
builder/googlecompute/config.go
builder/googlecompute/config.go
+3
-2
builder/openstack/builder.go
builder/openstack/builder.go
+2
-1
builder/parallels/iso/builder.go
builder/parallels/iso/builder.go
+2
-1
builder/parallels/pvm/config.go
builder/parallels/pvm/config.go
+2
-1
builder/qemu/builder.go
builder/qemu/builder.go
+2
-1
builder/virtualbox/ovf/config.go
builder/virtualbox/ovf/config.go
+2
-1
builder/vmware/iso/builder.go
builder/vmware/iso/builder.go
+2
-1
builder/vmware/vmx/config.go
builder/vmware/vmx/config.go
+2
-1
No files found.
builder/amazon/chroot/builder.go
View file @
84189f7a
...
...
@@ -35,7 +35,7 @@ type Config struct {
MountPath
string
`mapstructure:"mount_path"`
SourceAmi
string
`mapstructure:"source_ami"`
ctx
*
interpolate
.
Context
ctx
interpolate
.
Context
}
type
wrappedCommandTemplate
struct
{
...
...
@@ -48,10 +48,10 @@ type Builder struct {
}
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
b
.
config
.
ctx
=
&
interpolate
.
Context
{
Funcs
:
awscommon
.
TemplateFuncs
}
b
.
config
.
ctx
.
Funcs
=
awscommon
.
TemplateFuncs
err
:=
config
.
Decode
(
&
b
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
b
.
config
.
ctx
,
InterpolateContext
:
&
b
.
config
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"command_wrapper"
,
...
...
@@ -96,8 +96,8 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Accumulate any errors
var
errs
*
packer
.
MultiError
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AccessConfig
.
Prepare
(
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AMIConfig
.
Prepare
(
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AccessConfig
.
Prepare
(
&
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AMIConfig
.
Prepare
(
&
b
.
config
.
ctx
)
...
)
for
_
,
mounts
:=
range
b
.
config
.
ChrootMounts
{
if
len
(
mounts
)
!=
3
{
...
...
@@ -132,7 +132,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
ec2conn
:=
ec2
.
New
(
config
)
wrappedCommand
:=
func
(
command
string
)
(
string
,
error
)
{
ctx
:=
*
b
.
config
.
ctx
ctx
:=
b
.
config
.
ctx
ctx
.
Data
=
&
wrappedCommandTemplate
{
Command
:
command
}
return
interpolate
.
Render
(
b
.
config
.
CommandWrapper
,
&
ctx
)
}
...
...
builder/amazon/chroot/step_mount_device.go
View file @
84189f7a
...
...
@@ -33,7 +33,7 @@ func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction {
device
:=
state
.
Get
(
"device"
)
.
(
string
)
wrappedCommand
:=
state
.
Get
(
"wrappedCommand"
)
.
(
CommandWrapper
)
ctx
:=
*
config
.
ctx
ctx
:=
config
.
ctx
ctx
.
Data
=
&
mountPathData
{
Device
:
filepath
.
Base
(
device
)}
mountPath
,
err
:=
interpolate
.
Render
(
config
.
MountPath
,
&
ctx
)
...
...
builder/amazon/ebs/builder.go
View file @
84189f7a
...
...
@@ -29,7 +29,7 @@ type Config struct {
awscommon
.
BlockDevices
`mapstructure:",squash"`
awscommon
.
RunConfig
`mapstructure:",squash"`
ctx
*
interpolate
.
Context
ctx
interpolate
.
Context
}
type
Builder
struct
{
...
...
@@ -38,10 +38,10 @@ type Builder struct {
}
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
b
.
config
.
ctx
=
&
interpolate
.
Context
{
Funcs
:
awscommon
.
TemplateFuncs
}
b
.
config
.
ctx
.
Funcs
=
awscommon
.
TemplateFuncs
err
:=
config
.
Decode
(
&
b
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
b
.
config
.
ctx
,
InterpolateContext
:
&
b
.
config
.
ctx
,
},
raws
...
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -49,10 +49,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Accumulate any errors
var
errs
*
packer
.
MultiError
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AccessConfig
.
Prepare
(
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
BlockDevices
.
Prepare
(
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AMIConfig
.
Prepare
(
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
RunConfig
.
Prepare
(
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AccessConfig
.
Prepare
(
&
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
BlockDevices
.
Prepare
(
&
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AMIConfig
.
Prepare
(
&
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
RunConfig
.
Prepare
(
&
b
.
config
.
ctx
)
...
)
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
nil
,
errs
...
...
builder/amazon/instance/builder.go
View file @
84189f7a
...
...
@@ -41,7 +41,7 @@ type Config struct {
X509KeyPath
string
`mapstructure:"x509_key_path"`
X509UploadPath
string
`mapstructure:"x509_upload_path"`
ctx
*
interpolate
.
Context
ctx
interpolate
.
Context
}
type
Builder
struct
{
...
...
@@ -50,10 +50,10 @@ type Builder struct {
}
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
b
.
config
.
ctx
=
&
interpolate
.
Context
{
Funcs
:
awscommon
.
TemplateFuncs
}
b
.
config
.
ctx
.
Funcs
=
awscommon
.
TemplateFuncs
err
:=
config
.
Decode
(
&
b
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
b
.
config
.
ctx
,
InterpolateContext
:
&
b
.
config
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"bundle_upload_command"
,
...
...
@@ -114,10 +114,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Accumulate any errors
var
errs
*
packer
.
MultiError
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AccessConfig
.
Prepare
(
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
BlockDevices
.
Prepare
(
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AMIConfig
.
Prepare
(
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
RunConfig
.
Prepare
(
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AccessConfig
.
Prepare
(
&
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
BlockDevices
.
Prepare
(
&
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AMIConfig
.
Prepare
(
&
b
.
config
.
ctx
)
...
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
RunConfig
.
Prepare
(
&
b
.
config
.
ctx
)
...
)
if
b
.
config
.
AccountId
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"account_id is required"
))
...
...
builder/amazon/instance/step_bundle_volume.go
View file @
84189f7a
...
...
@@ -42,7 +42,7 @@ func (s *StepBundleVolume) Run(state multistep.StateBag) multistep.StepAction {
Prefix
:
config
.
BundlePrefix
,
PrivatePath
:
config
.
X509UploadPath
,
}
config
.
BundleVolCommand
,
err
=
interpolate
.
Render
(
config
.
BundleVolCommand
,
config
.
ctx
)
config
.
BundleVolCommand
,
err
=
interpolate
.
Render
(
config
.
BundleVolCommand
,
&
config
.
ctx
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error processing bundle volume command: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
...
...
builder/amazon/instance/step_upload_bundle.go
View file @
84189f7a
...
...
@@ -44,7 +44,7 @@ func (s *StepUploadBundle) Run(state multistep.StateBag) multistep.StepAction {
Region
:
region
,
SecretKey
:
config
.
SecretKey
,
}
config
.
BundleUploadCommand
,
err
=
interpolate
.
Render
(
config
.
BundleUploadCommand
,
config
.
ctx
)
config
.
BundleUploadCommand
,
err
=
interpolate
.
Render
(
config
.
BundleUploadCommand
,
&
config
.
ctx
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error processing bundle upload command: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
...
...
builder/digitalocean/config.go
View file @
84189f7a
...
...
@@ -31,7 +31,7 @@ type Config struct {
DropletName
string
`mapstructure:"droplet_name"`
UserData
string
`mapstructure:"user_data"`
ctx
*
interpolate
.
Context
ctx
interpolate
.
Context
}
func
NewConfig
(
raws
...
interface
{})
(
*
Config
,
[]
string
,
error
)
{
...
...
@@ -41,6 +41,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
err
:=
config
.
Decode
(
c
,
&
config
.
DecodeOpts
{
Metadata
:
&
md
,
Interpolate
:
true
,
InterpolateContext
:
&
c
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"run_command"
,
...
...
@@ -85,7 +86,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
var
errs
*
packer
.
MultiError
if
es
:=
c
.
Comm
.
Prepare
(
c
.
ctx
);
len
(
es
)
>
0
{
if
es
:=
c
.
Comm
.
Prepare
(
&
c
.
ctx
);
len
(
es
)
>
0
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
es
...
)
}
if
c
.
APIToken
==
""
{
...
...
builder/docker/config.go
View file @
84189f7a
...
...
@@ -39,6 +39,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
err
:=
config
.
Decode
(
c
,
&
config
.
DecodeOpts
{
Metadata
:
&
md
,
Interpolate
:
true
,
InterpolateContext
:
&
c
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"run_command"
,
...
...
builder/googlecompute/config.go
View file @
84189f7a
...
...
@@ -41,13 +41,14 @@ type Config struct {
account
accountFile
privateKeyBytes
[]
byte
stateTimeout
time
.
Duration
ctx
*
interpolate
.
Context
ctx
interpolate
.
Context
}
func
NewConfig
(
raws
...
interface
{})
(
*
Config
,
[]
string
,
error
)
{
c
:=
new
(
Config
)
err
:=
config
.
Decode
(
c
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
&
c
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"run_command"
,
...
...
builder/openstack/builder.go
View file @
84189f7a
...
...
@@ -36,6 +36,7 @@ type Builder struct {
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
err
:=
config
.
Decode
(
&
b
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
&
b
.
config
.
ctx
,
},
raws
...
)
if
err
!=
nil
{
return
nil
,
err
...
...
builder/parallels/iso/builder.go
View file @
84189f7a
...
...
@@ -58,6 +58,7 @@ type Config struct {
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
err
:=
config
.
Decode
(
&
b
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
&
b
.
config
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"boot_command"
,
...
...
builder/parallels/pvm/config.go
View file @
84189f7a
...
...
@@ -35,6 +35,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c
:=
new
(
Config
)
err
:=
config
.
Decode
(
c
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
&
c
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"boot_command"
,
...
...
builder/qemu/builder.go
View file @
84189f7a
...
...
@@ -128,6 +128,7 @@ type Config struct {
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
err
:=
config
.
Decode
(
&
b
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
&
b
.
config
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"boot_command"
,
...
...
builder/virtualbox/ovf/config.go
View file @
84189f7a
...
...
@@ -43,6 +43,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c
:=
new
(
Config
)
err
:=
config
.
Decode
(
c
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
&
c
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"boot_command"
,
...
...
builder/vmware/iso/builder.go
View file @
84189f7a
...
...
@@ -69,6 +69,7 @@ type Config struct {
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
err
:=
config
.
Decode
(
&
b
.
config
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
&
b
.
config
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"boot_command"
,
...
...
builder/vmware/vmx/config.go
View file @
84189f7a
...
...
@@ -36,6 +36,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c
:=
new
(
Config
)
err
:=
config
.
Decode
(
c
,
&
config
.
DecodeOpts
{
Interpolate
:
true
,
InterpolateContext
:
&
c
.
ctx
,
InterpolateFilter
:
&
interpolate
.
RenderFilter
{
Exclude
:
[]
string
{
"boot_command"
,
...
...
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