Implemented DEFAULT_NAME handling for datasource plugins (#11026)

This commit is contained in:
Ilya Voronin 2021-05-18 11:47:43 +03:00 committed by GitHub
parent b6db1ac319
commit 6867456a72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -320,7 +320,11 @@ func (c *PluginConfig) DiscoverMultiPlugin(pluginName, pluginPath string) error
for _, datasourceName := range desc.Datasources {
datasourceName := datasourceName // copy to avoid pointer overwrite issue
c.DataSources.Set(pluginPrefix+datasourceName, func() (packersdk.Datasource, error) {
key := pluginPrefix + datasourceName
if datasourceName == pluginsdk.DEFAULT_NAME {
key = pluginName
}
c.DataSources.Set(key, func() (packersdk.Datasource, error) {
return c.Client(pluginPath, "start", "datasource", datasourceName).Datasource()
})
}