diff --git a/command/plugins_install.go b/command/plugins_install.go index 3f086168cd8..b1d6c361318 100644 --- a/command/plugins_install.go +++ b/command/plugins_install.go @@ -160,6 +160,18 @@ func (c *PluginsInstallCommand) RunContext(buildCtx context.Context, args *Plugi c.Ui.Error(err.Error()) return 1 } + + hasPrerelease := false + for _, con := range constraints { + if con.Prerelease() { + hasPrerelease = true + } + } + if hasPrerelease { + c.Ui.Errorf("Unsupported prerelease for constraint %q", args.Version) + return 1 + } + pluginRequirement.VersionConstraints = constraints } diff --git a/hcl2template/types.required_plugins.go b/hcl2template/types.required_plugins.go index 59a8018004f..08fe694b3ac 100644 --- a/hcl2template/types.required_plugins.go +++ b/hcl2template/types.required_plugins.go @@ -141,6 +141,22 @@ func decodeRequiredPluginsBlock(block *hcl.Block) (*RequiredPlugins, hcl.Diagnos }) continue } + + hadPrerelease := false + for _, constraint := range constraints { + if constraint.Prerelease() { + hadPrerelease = true + } + } + if hadPrerelease { + diags = diags.Append(&hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: "Invalid version constraint", + Detail: fmt.Sprintf("Unsupported prerelease for constraint %q", constraintStr), + Subject: attr.Expr.Range().Ptr(), + }) + } + vc.Required = constraints rp.Requirement = vc