Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix terragrunt parsing #409

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/param_parsing/terragrunt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func GetVersionFromTerragrunt(params Params) (Params, error) {
}
var versionFromTerragrunt terragruntVersionConstraints
diagnostics = gohcl.DecodeBody(hclFile.Body, nil, &versionFromTerragrunt)
if diagnostics.HasErrors() {
return params, fmt.Errorf("could not decode body of HCL file %q", filePath)
if versionFromTerragrunt.TerraformVersionConstraint == "" {
return params, fmt.Errorf("could not find terraform_version_constraint in file %q", filePath)
MatrixCrawler marked this conversation as resolved.
Show resolved Hide resolved
}
version, err := lib.GetSemver(versionFromTerragrunt.TerraformVersionConstraint, params.MirrorURL)
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions lib/param_parsing/terragrunt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ import (

func TestGetVersionFromTerragrunt(t *testing.T) {
var params Params
logger = lib.InitLogger("DEBUG")
params = initParams(params)
params.ChDirPath = "../../test-data/integration-tests/test_terragrunt_hcl"
params, _ = GetVersionFromTerragrunt(params)
params, err := GetVersionFromTerragrunt(params)
if err != nil {
t.Fatalf("Got error '%s'", err)
}
v1, _ := version.NewVersion("0.13")
v2, _ := version.NewVersion("0.14")
actualVersion, _ := version.NewVersion(params.Version)
Expand Down Expand Up @@ -40,7 +44,7 @@ func TestGetVersionFromTerragrunt_erroneous_file(t *testing.T) {
if err == nil {
t.Error("Expected error but got none.")
} else {
expectedError := "could not decode body of HCL file"
expectedError := "could not find terraform_version_constraint in file"
if !strings.Contains(err.Error(), expectedError) {
t.Errorf("Expected error to contain '%q', got '%q'", expectedError, err)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
terragrunt_version_constraint = "= 0.36.2"
terraform_version_constraint = ">= 0.13, < 0.14"