Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use newest plugin when multiple versions are found #2

Merged
merged 1 commit into from Jul 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions tfschema/client.go
Expand Up @@ -63,12 +63,13 @@ func findPlugin(pluginType string, pluginName string) (*discovery.PluginMeta, er
return nil, err
}

pluginMetaSet := discovery.FindPlugins(pluginType, dirs)
pluginMetaSet := discovery.FindPlugins(pluginType, dirs).WithName(pluginName)

for plugin := range pluginMetaSet {
if plugin.Name == pluginName {
return &plugin, nil
}
// if pluginMetaSet doesn't have any pluginMeta, pluginMetaSet.Newest() will call panic.
// so check it here.
if pluginMetaSet.Count() > 0 {
ret := pluginMetaSet.Newest()
return &ret, nil
}

return nil, fmt.Errorf("Failed to find plugin: %s. Plugin binary was not found in any of the following directories: [%s]", pluginName, strings.Join(dirs, ", "))
Expand Down