Implement support for multiple Terraform version constraints from the module directory
Closed this issue · 0 comments
yermulnik commented
When parsing Terraform version constraint from the module directory, only the first constraint found is taken into account, whilst Terraform configuration supports multiple terraform {}
configuration blocks and each may have its own required_version
parameter.
To improve Terraform versions detection the code needs to be adjusted to gather all the constraints and leverage combined constraint string to detect allowed required Terraform version.
Refs:
- Relevant existing code:
Line 443 in f268ab5
- Discussion: #356 (comment)
- Simplified implementation example:
func installTFProvidedModule(dir string, custBinPath, mirrorURL *string) { fmt.Printf("Reading required version from terraform file\n") module, _ := tfconfig.LoadModule(dir) var tfconstraints []string for key := range module.RequiredCore { tfconstraints = append(tfconstraints, module.RequiredCore[key]) } tfconstraint := strings.Join(tfconstraints, ", ") installFromConstraint(&tfconstraint, custBinPath, mirrorURL) }