From ec92d231bc54f93227aea0272b9d34107b35e077 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 15 May 2024 19:05:16 -0400 Subject: [PATCH] packer: use filepath for getting plugin basename When Discovering plugins installed through the `Discover` function, we use the base name of the plugin binary we discovered preliminarly, then we match its name against a regex to extract the prefix for the plugin's components. Extracting the base path used to be done with `path.Base`, which while working perfectly on UNIX systems, does not on Windows as it uses `\\` as their path separator. To circumvent this problem, we use the `filepath` package to extract the base name of the plugin instead, making the discovery logic work again on Windows. --- packer/plugin.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packer/plugin.go b/packer/plugin.go index c4fe1845cab..5939d6aa6ab 100644 --- a/packer/plugin.go +++ b/packer/plugin.go @@ -9,7 +9,6 @@ import ( "log" "os" "os/exec" - "path" "path/filepath" "regexp" "runtime" @@ -103,7 +102,7 @@ func (c *PluginConfig) Discover() error { // We'll use that later to register the components for each plugin pluginMap := map[string]string{} for _, install := range installations { - pluginBasename := path.Base(install.BinaryPath) + pluginBasename := filepath.Base(install.BinaryPath) matches := extractPluginBasename.FindStringSubmatch(pluginBasename) if len(matches) != 2 { log.Printf("[INFO] - plugin %q could not have its name matched, ignoring", pluginBasename)