From c049c19b2531f15446dd34678e95296c0d100677 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 23 May 2013 21:39:00 -0700 Subject: [PATCH] Support provisioners in global config --- config.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/config.go b/config.go index 903ee6638..fb555cd6f 100644 --- a/config.go +++ b/config.go @@ -21,6 +21,7 @@ build = "packer-command-build" type config struct { Builders map[string]string Commands map[string]string + Provisioners map[string]string } // Merge the configurations. Anything in the "new" configuration takes @@ -37,6 +38,10 @@ func mergeConfig(a, b *config) *config { for k, v := range config.Commands { result.Commands[k] = v } + + for k, v := range config.Provisioners { + result.Provisioners[k] = v + } } return result @@ -47,6 +52,7 @@ func newConfig() *config { result := new(config) result.Builders = make(map[string]string) result.Commands = make(map[string]string) + result.Provisioners = make(map[string]string) return result } @@ -95,3 +101,14 @@ func (c *config) LoadHook(name string) (packer.Hook, error) { log.Printf("Loading hook: %s\n", 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)) +}