Skip to content

Commit

Permalink
packer: fix listing on windows with .exe ext
Browse files Browse the repository at this point in the history
Listing installed plugins on Windows requires the extension to be set in
the ListOptions, otherwise they are not discovered.

While working on the discovery code, and consolidating it in a single
location, we've forgotten to pass the argument to ListInstallations, so
that makes it impossible to automatically discover installed components
on Windows.

This commit fixes this issue for the plugins required, and the general
discovery process during build/validate.
  • Loading branch information
lbajolet-hashicorp committed May 16, 2024
1 parent 682968d commit a852434
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions command/plugins_required.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@ func (c *PluginsRequiredCommand) RunContext(buildCtx context.Context, cla *Plugi
return ret
}

ext := ""
if runtime.GOOS == "windows" {
ext = ".exe"
}
opts := plugingetter.ListInstallationsOptions{
PluginDirectory: c.Meta.CoreConfig.Components.PluginConfig.PluginDirectory,
BinaryInstallationOptions: plugingetter.BinaryInstallationOptions{
OS: runtime.GOOS,
ARCH: runtime.GOARCH,
Ext: ext,
APIVersionMajor: pluginsdk.APIVersionMajor,
APIVersionMinor: pluginsdk.APIVersionMinor,
Checksummers: []plugingetter.Checksummer{
Expand Down
6 changes: 6 additions & 0 deletions packer/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,17 @@ func (c *PluginConfig) Discover() error {
c.PluginDirectory, _ = PluginFolder()
}

ext := ""
if runtime.GOOS == "windows" {
ext = ".exe"
}

installations, err := plugingetter.Requirement{}.ListInstallations(plugingetter.ListInstallationsOptions{
PluginDirectory: c.PluginDirectory,
BinaryInstallationOptions: plugingetter.BinaryInstallationOptions{
OS: runtime.GOOS,
ARCH: runtime.GOARCH,
Ext: ext,
APIVersionMajor: pluginsdk.APIVersionMajor,
APIVersionMinor: pluginsdk.APIVersionMinor,
Checksummers: []plugingetter.Checksummer{
Expand Down

0 comments on commit a852434

Please sign in to comment.