deps: limit Terraform version to FOSS releases (#2241)

* deps: limit Terraform version to FOSS releases

* fix: enforce upper version constraint

---------

Co-authored-by: Leonard Cohnen <lc@edgeless.systems>
This commit is contained in:
Thomas Tendyck 2023-08-16 23:25:53 +02:00 committed by GitHub
parent c6819b8d31
commit 587ae6a575
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,8 @@ import (
) )
const ( const (
tfVersion = ">= 1.4.6" // Enforce "<1.6.0" to ensure that only MPL licensed Terraform versions are used.
tfVersion = ">= 1.4.6, < 1.6.0"
terraformVarsFile = "terraform.tfvars" terraformVarsFile = "terraform.tfvars"
// terraformUpgradePlanFile is the file name of the zipfile created by Terraform plan for Constellation upgrades. // terraformUpgradePlanFile is the file name of the zipfile created by Terraform plan for Constellation upgrades.
@ -521,10 +522,19 @@ func GetExecutable(ctx context.Context, workingDir string) (terraform *tfexec.Te
return nil, nil, err return nil, nil, err
} }
downloadVersion := &releases.LatestVersion{ constrainedVersions := &releases.Versions{
Product: product.Terraform, Product: product.Terraform,
Constraints: version, Constraints: version,
} }
installCandidates, err := constrainedVersions.List(ctx)
if err != nil {
return nil, nil, err
}
if len(installCandidates) == 0 {
return nil, nil, fmt.Errorf("no Terraform version found for constraint %s", version)
}
downloadVersion := installCandidates[len(installCandidates)-1]
localVersion := &fs.Version{ localVersion := &fs.Version{
Product: product.Terraform, Product: product.Terraform,
Constraints: version, Constraints: version,