fix discover.go

This commit is contained in:
Megan Marsh 2021-01-07 15:38:38 -08:00
parent c94d66db13
commit beba3a90a9
1 changed files with 15 additions and 3 deletions

View File

@ -236,7 +236,11 @@ func (c *Config) discoverMultiPlugin(pluginName, pluginPath string) error {
for _, builderName := range desc.Builders {
builderName := builderName // copy to avoid pointer overwrite issue
c.builders[pluginPrefix+builderName] = func() (packersdk.Builder, error) {
key := pluginPrefix + builderName
if builderName == pluginsdk.DEFAULT_NAME {
key = pluginName
}
c.builders[key] = func() (packersdk.Builder, error) {
return c.Client(pluginPath, "start", "builder", builderName).Builder()
}
}
@ -247,7 +251,11 @@ func (c *Config) discoverMultiPlugin(pluginName, pluginPath string) error {
for _, postProcessorName := range desc.PostProcessors {
postProcessorName := postProcessorName // copy to avoid pointer overwrite issue
c.postProcessors[pluginPrefix+postProcessorName] = func() (packersdk.PostProcessor, error) {
key := pluginPrefix + postProcessorName
if postProcessorName == pluginsdk.DEFAULT_NAME {
key = pluginName
}
c.postProcessors[key] = func() (packersdk.PostProcessor, error) {
return c.Client(pluginPath, "start", "post-processor", postProcessorName).PostProcessor()
}
}
@ -258,7 +266,11 @@ func (c *Config) discoverMultiPlugin(pluginName, pluginPath string) error {
for _, provisionerName := range desc.Provisioners {
provisionerName := provisionerName // copy to avoid pointer overwrite issue
c.provisioners[pluginPrefix+provisionerName] = func() (packersdk.Provisioner, error) {
key := pluginPrefix + provisionerName
if provisionerName == pluginsdk.DEFAULT_NAME {
key = pluginName
}
c.provisioners[key] = func() (packersdk.Provisioner, error) {
return c.Client(pluginPath, "start", "provisioner", provisionerName).Provisioner()
}
}