From 62af8ea8d4b44a5757788e33a2ebd2ec2f522a90 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Thu, 1 Feb 2024 15:47:57 -0500 Subject: [PATCH] packer: always reject plugin pre-releases When a pre-release version of a plugin is locally installed, it may or may not be loaded depending on the constraints expressed in the template being executed. If the template contains constraints for loading the plugin, it would be ignored, while if that wasn't present, it would be loaded. This is inconsistent, and deserves to be addressed, which is what this commit does. With this change, plugin pre-releases are now always rejected with a message in the verbose logs, so only releases are considered, whether or not the template being processed contains a `required_plugins` constraint or not. --- packer/plugin-getter/plugins.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packer/plugin-getter/plugins.go b/packer/plugin-getter/plugins.go index 11511ee38..b9b64e57c 100644 --- a/packer/plugin-getter/plugins.go +++ b/packer/plugin-getter/plugins.go @@ -159,6 +159,11 @@ func (pr Requirement) ListInstallations(opts ListInstallationsOptions) (InstallL continue } + if pv.Prerelease() != "" { + log.Printf("pre-release version of plugin %q discovered: unsupported, ignoring", path) + continue + } + if strings.Replace(pluginVersionStr, "v", "", -1) != describeInfo.Version { log.Printf("plugin %q reported version %s while its name implies version %s, ignoring", path, describeInfo.Version, pluginVersionStr) continue