diff --git a/packer/plugin/discover.go b/packer/plugin/discover.go index fd636a177..823c186b7 100644 --- a/packer/plugin/discover.go +++ b/packer/plugin/discover.go @@ -37,9 +37,16 @@ func (c *Config) GetPlugins() (packer.MapOfBuilder, packer.MapOfProvisioner, pac // Hence, the priority order is the reverse of the search order - i.e., the // CWD has the highest priority. func (c *Config) Discover() error { - c.builders = packer.MapOfBuilder{} - c.postProcessors = packer.MapOfPostProcessor{} - c.provisioners = packer.MapOfProvisioner{} + if c.builders == nil { + c.builders = packer.MapOfBuilder{} + } + if c.provisioners == nil { + c.provisioners = packer.MapOfProvisioner{} + } + if c.postProcessors == nil { + c.postProcessors = packer.MapOfPostProcessor{} + } + // If we are already inside a plugin process we should not need to // discover anything. if os.Getenv(MagicCookieKey) == MagicCookieValue {