cloud: Fix prerelease version constraint checks
This commit is contained in:
parent
3cd6c0be7a
commit
a61bd8a96b
|
@ -838,10 +838,13 @@ func (b *Cloud) VerifyWorkspaceTerraformVersion(workspaceName string) tfdiags.Di
|
|||
return diags
|
||||
}
|
||||
|
||||
// If the workspace has a literal Terraform version, see if we can use a
|
||||
// looser version constraint.
|
||||
remoteVersion, _ := version.NewSemver(workspace.TerraformVersion)
|
||||
if remoteVersion != nil {
|
||||
|
||||
// We can use a looser version constraint if the workspace specifies a
|
||||
// literal Terraform version, and it is not a prerelease. The latter
|
||||
// restriction is because we cannot compare prerelease versions with any
|
||||
// operator other than simple equality.
|
||||
if remoteVersion != nil && remoteVersion.Prerelease() == "" {
|
||||
v014 := version.Must(version.NewSemver("0.14.0"))
|
||||
v120 := version.Must(version.NewSemver("1.2.0"))
|
||||
|
||||
|
@ -883,7 +886,7 @@ func (b *Cloud) VerifyWorkspaceTerraformVersion(workspaceName string) tfdiags.Di
|
|||
tfversion.String(),
|
||||
b.organization,
|
||||
workspace.Name,
|
||||
workspace.TerraformVersion,
|
||||
remoteConstraint,
|
||||
)
|
||||
diags = diags.Append(incompatibleWorkspaceTerraformVersion(message, b.ignoreVersionConflict))
|
||||
return diags
|
||||
|
|
|
@ -701,6 +701,7 @@ func TestCloud_VerifyWorkspaceTerraformVersion(t *testing.T) {
|
|||
// pre-release versions are comparable within their pre-release stage (dev,
|
||||
// alpha, beta), but not comparable to different stages and not comparable
|
||||
// to final releases.
|
||||
{"1.1.0-beta1", "1.1.0-beta1", true, false},
|
||||
{"1.1.0-beta1", "~> 1.1.0-beta", true, false},
|
||||
{"1.1.0", "~> 1.1.0-beta", true, true},
|
||||
{"1.1.0-beta1", "~> 1.1.0-dev", true, true},
|
||||
|
|
Loading…
Reference in New Issue