From 7f43b65c68cec561b510cd9d76119cc8089e48b0 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Fri, 24 Nov 2023 11:20:54 -0500 Subject: [PATCH] command: plugins install reject non-releases When installing a plugin with packer plugins install --path, we only accept release versions of a plugin, as otherwise the loading can be inconsistent if for example a user specifies a required_plugins block in their template, in which case the plugins will be ignored. Until we have a simpler loading scheme then, we will reject non-release versions of plugins to avoid confusion. --- command/plugins_install.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/command/plugins_install.go b/command/plugins_install.go index 81b74cbd601..f6d7b11086e 100644 --- a/command/plugins_install.go +++ b/command/plugins_install.go @@ -263,6 +263,14 @@ an issue on our Github repo to signal it.`) }}) } + if strings.Contains(desc.Version, "-") { + return writeDiags(c.Ui, nil, hcl.Diagnostics{&hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: "Invalid version", + Detail: fmt.Sprintf("Packer can only install plugin releases with this command (ex: 1.0.0), the binary's reported version is %q", desc.Version), + }}) + } + pluginBinary, err := os.Open(args.PluginPath) if err != nil { return writeDiags(c.Ui, nil, hcl.Diagnostics{&hcl.Diagnostic{