From b24ab44a555f6cb48ff841bc275c3835d9acfa03 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Thu, 2 May 2024 09:52:51 -0400 Subject: [PATCH] command: list releases only for remote installs When installing a plugin from a remote source, we list the installed plugins that match the constraints specified, and if the constraint is already satisfied, we don't do anything. However, since remote installation is only relevant for releases of a plugin, we should only look at the installed releases of a plugin, and not consider pre-releases for that step. This wasn't the case before this commit, as if a prerelease version of a commit (ex: 10.8.1-dev), and we try to invoke `packer init` with a constraint on this version specifically, Packer would locate that pre-release and assume it was already installed, so would silently succeed the command and do nothing. This isn't the expected behaviour as we should install the final release of that plugin, regardless of any prerelease installation of the plugin. So this commit fixes that by only listing releases, so we don't report the plugin being already installed if a prerelease is what's installed. --- command/init.go | 1 + command/plugins_install.go | 1 + 2 files changed, 2 insertions(+) diff --git a/command/init.go b/command/init.go index 100549174..a9a993426 100644 --- a/command/init.go +++ b/command/init.go @@ -85,6 +85,7 @@ for more info.`) Checksummers: []plugingetter.Checksummer{ {Type: "sha256", Hash: sha256.New()}, }, + ReleasesOnly: true, }, } diff --git a/command/plugins_install.go b/command/plugins_install.go index 59e197a3f..57419f827 100644 --- a/command/plugins_install.go +++ b/command/plugins_install.go @@ -130,6 +130,7 @@ func (c *PluginsInstallCommand) RunContext(buildCtx context.Context, args *Plugi Checksummers: []plugingetter.Checksummer{ {Type: "sha256", Hash: sha256.New()}, }, + ReleasesOnly: true, }, } if runtime.GOOS == "windows" {