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

Conversation

yamamoto-febc
Copy link
Contributor

This PR changes to always use newest plugin version when multiple versions found.

background

If you have multiple plugin versions as follows:

$ ls -1 ~/.terraform.d/plugins/
terraform-provider-foobar_v1.0.0_x4
terraform-provider-foobar_v1.1.0_x4

tfschema uses foobar's v1.0.0 or v1.1.0 randomly.

The cause is in the following part.

pluginMetaSet := discovery.FindPlugins(pluginType, dirs)
for plugin := range pluginMetaSet {
if plugin.Name == pluginName {
return &plugin, nil
}
}

discovery.FindPlugins returns discovery.PluginMetaSet.
It is defined as map[PluginMeta]struct{}.
https://github.com/hashicorp/terraform/blob/v0.11.7/plugin/discovery/meta_set.go#L7
So its iteration order is not guaranteed.

Copy link
Owner

@minamijoyo minamijoyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@minamijoyo
Copy link
Owner

@yamamoto-febc Thank you for your contribution!

@minamijoyo minamijoyo merged commit a0a38a1 into minamijoyo:master Jul 27, 2018
@yamamoto-febc yamamoto-febc deleted the use_newest_version branch July 27, 2018 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants