Explicit version strings are actually also version constraints! And the special
comparisons we were doing to allow a range of compatible versions can also be
expressed as version constraints.
Bonus: also simplify the way we handle version check errors, by composing the
messages inline and only extracting the repetitive parts into a function.
suggestion:="If you're sure you want to upgrade the state, you can force Terraform to continue using the -ignore-remote-version flag. This may result in an unusable workspace."
ifignoreVersionConflict{
suggestion=""
}
constignoreRemoteVersionHelp="If you're sure you want to upgrade the state, you can force Terraform to continue using the -ignore-remote-version flag. This may result in an unusable workspace."
description:=fmt.Sprintf(
"The local Terraform version (%s) does not meet the version requirements for remote workspace %s/%s (%s).\n\n%s",
tfversion,
organization,
workspace.Name,
workspace.TerraformVersion,
suggestion,
)
description=strings.TrimSpace(description)
returntfdiags.Sourceless(severity,"Terraform version mismatch",description)
suggestion:="If you're sure you want to upgrade the state, you can force Terraform to continue using the -ignore-remote-version flag. This may result in an unusable workspace."
ifignoreVersionConflict{
suggestion=""
}
description:=fmt.Sprintf("The remote workspace specified an invalid Terraform version or version constraint: %s\n\n%s",tfversion,suggestion)
description=strings.TrimSpace(description)
returntfdiags.Sourceless(severity,"Terraform version error",description)