Commit 332bdf6e authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/*, provisioner/*: set user vars

parent 670c6c5c
...@@ -52,6 +52,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -52,6 +52,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
if err != nil { if err != nil {
return err return err
} }
b.config.tpl.UserVars = b.config.PackerUserVars
// Defaults // Defaults
if b.config.ChrootMounts == nil { if b.config.ChrootMounts == nil {
......
...@@ -45,6 +45,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -45,6 +45,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
if err != nil { if err != nil {
return err return err
} }
b.config.tpl.UserVars = b.config.PackerUserVars
// Accumulate any errors // Accumulate any errors
errs := common.CheckUnusedConfig(md) errs := common.CheckUnusedConfig(md)
......
...@@ -55,6 +55,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -55,6 +55,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
if err != nil { if err != nil {
return err return err
} }
b.config.tpl.UserVars = b.config.PackerUserVars
if b.config.BundleDestination == "" { if b.config.BundleDestination == "" {
b.config.BundleDestination = "/tmp" b.config.BundleDestination = "/tmp"
......
...@@ -61,6 +61,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -61,6 +61,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
if err != nil { if err != nil {
return err return err
} }
b.config.tpl.UserVars = b.config.PackerUserVars
// Accumulate any errors // Accumulate any errors
errs := common.CheckUnusedConfig(md) errs := common.CheckUnusedConfig(md)
......
...@@ -70,6 +70,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -70,6 +70,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
if err != nil { if err != nil {
return err return err
} }
b.config.tpl.UserVars = b.config.PackerUserVars
// Accumulate any errors // Accumulate any errors
errs := common.CheckUnusedConfig(md) errs := common.CheckUnusedConfig(md)
......
...@@ -71,6 +71,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -71,6 +71,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
if err != nil { if err != nil {
return err return err
} }
b.config.tpl.UserVars = b.config.PackerUserVars
// Accumulate any errors // Accumulate any errors
errs := common.CheckUnusedConfig(md) errs := common.CheckUnusedConfig(md)
......
...@@ -9,6 +9,8 @@ import ( ...@@ -9,6 +9,8 @@ import (
) )
type config struct { type config struct {
common.PackerConfig `mapstructure:",squash"`
// The local path of the file to upload. // The local path of the file to upload.
Source string Source string
...@@ -32,6 +34,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { ...@@ -32,6 +34,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
if err != nil { if err != nil {
return err return err
} }
p.config.tpl.UserVars = p.config.PackerUserVars
// Accumulate any errors // Accumulate any errors
errs := common.CheckUnusedConfig(md) errs := common.CheckUnusedConfig(md)
......
...@@ -17,6 +17,8 @@ import ( ...@@ -17,6 +17,8 @@ import (
const DefaultRemotePath = "/tmp/script.sh" const DefaultRemotePath = "/tmp/script.sh"
type config struct { type config struct {
common.PackerConfig `mapstructure:",squash"`
// An inline script to execute. Multiple strings are all executed // An inline script to execute. Multiple strings are all executed
// in the context of a single shell. // in the context of a single shell.
Inline []string Inline []string
...@@ -43,10 +45,6 @@ type config struct { ...@@ -43,10 +45,6 @@ type config struct {
// can be used to inject the environment_vars into the environment. // can be used to inject the environment_vars into the environment.
ExecuteCommand string `mapstructure:"execute_command"` ExecuteCommand string `mapstructure:"execute_command"`
// Packer configurations, these come from Packer itself
PackerBuildName string `mapstructure:"packer_build_name"`
PackerBuilderType string `mapstructure:"packer_builder_type"`
tpl *common.Template tpl *common.Template
} }
...@@ -69,6 +67,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { ...@@ -69,6 +67,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
if err != nil { if err != nil {
return err return err
} }
p.config.tpl.UserVars = p.config.PackerUserVars
// Accumulate any errors // Accumulate any errors
errs := common.CheckUnusedConfig(md) errs := common.CheckUnusedConfig(md)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment