Commit c049c19b authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Support provisioners in global config

parent 9dfb5365
...@@ -21,6 +21,7 @@ build = "packer-command-build" ...@@ -21,6 +21,7 @@ build = "packer-command-build"
type config struct { type config struct {
Builders map[string]string Builders map[string]string
Commands map[string]string Commands map[string]string
Provisioners map[string]string
} }
// Merge the configurations. Anything in the "new" configuration takes // Merge the configurations. Anything in the "new" configuration takes
...@@ -37,6 +38,10 @@ func mergeConfig(a, b *config) *config { ...@@ -37,6 +38,10 @@ func mergeConfig(a, b *config) *config {
for k, v := range config.Commands { for k, v := range config.Commands {
result.Commands[k] = v result.Commands[k] = v
} }
for k, v := range config.Provisioners {
result.Provisioners[k] = v
}
} }
return result return result
...@@ -47,6 +52,7 @@ func newConfig() *config { ...@@ -47,6 +52,7 @@ func newConfig() *config {
result := new(config) result := new(config)
result.Builders = make(map[string]string) result.Builders = make(map[string]string)
result.Commands = make(map[string]string) result.Commands = make(map[string]string)
result.Provisioners = make(map[string]string)
return result return result
} }
...@@ -95,3 +101,14 @@ func (c *config) LoadHook(name string) (packer.Hook, error) { ...@@ -95,3 +101,14 @@ func (c *config) LoadHook(name string) (packer.Hook, error) {
log.Printf("Loading hook: %s\n", name) log.Printf("Loading hook: %s\n", name)
return plugin.Hook(exec.Command(name)) return plugin.Hook(exec.Command(name))
} }
func (c *config) LoadProvisioner(name string) (packer.Provisioner, error) {
log.Printf("Loading provisioner: %s\n", name)
provBin, ok := c.Provisioners[name]
if !ok {
log.Printf("Provisioner not found: %s\n", name)
return nil, nil
}
return plugin.Provisioner(exec.Command(provBin))
}
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