plugin/discovery: handle the -Xn suffix used by auto-installed plugins
This is used to mark the plugin protocol version. Currently we actually just ignore this entirely, since only one protocol version exists anyway. Later we will need to add checks here to ensure that we only pay attention to plugins of the right version.
This commit is contained in:
parent
6ba6508ec9
commit
04bcece59c
|
@ -147,6 +147,12 @@ func ResolvePluginPaths(paths []string) PluginMetaSet {
|
|||
version = parts[1]
|
||||
}
|
||||
|
||||
// Auto-installed plugins contain an extra name portion representing
|
||||
// the expected plugin version, which we must trim off.
|
||||
if dashX := strings.Index(version, "-X"); dashX != -1 {
|
||||
version = version[:dashX]
|
||||
}
|
||||
|
||||
if _, ok := found[nameVersion{name, version}]; ok {
|
||||
// Skip duplicate versions of the same plugin
|
||||
// (We do this during this step because after this we will be
|
||||
|
|
|
@ -53,6 +53,7 @@ func TestResolvePluginPaths(t *testing.T) {
|
|||
"/example/mockos_mockarch/terraform-foo-bar-V0.0.1",
|
||||
"/example/mockos_mockarch/terraform-foo-baz-V0.0.1",
|
||||
"/example/mockos_mockarch/terraform-foo-baz-V1.0.0",
|
||||
"/example/mockos_mockarch/terraform-foo-baz-V2.0.0-X4",
|
||||
"/example/terraform-foo-bar",
|
||||
"/example/mockos_mockarch/terraform-foo-bar-Vbananas",
|
||||
"/example/mockos_mockarch/terraform-foo-bar-V",
|
||||
|
@ -75,6 +76,11 @@ func TestResolvePluginPaths(t *testing.T) {
|
|||
Version: "1.0.0",
|
||||
Path: "/example/mockos_mockarch/terraform-foo-baz-V1.0.0",
|
||||
},
|
||||
{
|
||||
Name: "baz",
|
||||
Version: "2.0.0",
|
||||
Path: "/example/mockos_mockarch/terraform-foo-baz-V2.0.0-X4",
|
||||
},
|
||||
{
|
||||
Name: "bar",
|
||||
Version: "0.0.0",
|
||||
|
@ -92,6 +98,8 @@ func TestResolvePluginPaths(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
t.Logf("got %#v", got)
|
||||
|
||||
if got, want := got.Count(), len(want); got != want {
|
||||
t.Errorf("got %d items; want %d", got, want)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue