File tree 9 files changed +36
-2
lines changed
dir-with-terraform-and-tofu
dir-with-terraform-and-tofu-json
9 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ func (err BackendNotDefined) Error() string {
39
39
type NoTerraformFilesFound string
40
40
41
41
func (path NoTerraformFilesFound ) Error () string {
42
- return "Did not find any Terraform files (*.tf) in " + string (path )
42
+ return "Did not find any Terraform files (*.tf) or OpenTofu files (*.tofu) in " + string (path )
43
43
}
44
44
45
45
type ModuleIsProtected struct {
Original file line number Diff line number Diff line change @@ -540,13 +540,27 @@ func CheckFolderContainsTerraformCode(terragruntOptions *options.TerragruntOptio
540
540
541
541
files = append (files , hclFiles ... )
542
542
543
+ tofuHclFiles , err := zglob .Glob (terragruntOptions .WorkingDir + "/**/*.tofu" )
544
+ if err != nil {
545
+ return errors .New (err )
546
+ }
547
+
548
+ files = append (files , tofuHclFiles ... )
549
+
543
550
jsonFiles , err := zglob .Glob (terragruntOptions .WorkingDir + "/**/*.tf.json" )
544
551
if err != nil {
545
552
return errors .New (err )
546
553
}
547
554
548
555
files = append (files , jsonFiles ... )
549
556
557
+ tofuJSONFiles , err := zglob .Glob (terragruntOptions .WorkingDir + "/**/*.tofu.json" )
558
+ if err != nil {
559
+ return errors .New (err )
560
+ }
561
+
562
+ files = append (files , tofuJSONFiles ... )
563
+
550
564
if len (files ) == 0 {
551
565
return errors .New (NoTerraformFilesFound (terragruntOptions .WorkingDir ))
552
566
}
Original file line number Diff line number Diff line change @@ -96,13 +96,33 @@ func TestTerragruntTerraformCodeCheck(t *testing.T) {
96
96
workingDir : "test-fixtures/dir-with-terraform" ,
97
97
valid : true ,
98
98
},
99
+ {
100
+ description : "Directory with plain OpenTofu" ,
101
+ workingDir : "test-fixtures/dir-with-tofu" ,
102
+ valid : true ,
103
+ },
104
+ {
105
+ description : "Directory with plain Terraform and OpenTofu" ,
106
+ workingDir : "test-fixtures/dir-with-terraform-and-tofu" ,
107
+ valid : true ,
108
+ },
99
109
{
100
110
description : "Directory with JSON formatted Terraform" ,
101
111
workingDir : "test-fixtures/dir-with-terraform-json" ,
102
112
valid : true ,
103
113
},
104
114
{
105
- description : "Directory with no Terraform" ,
115
+ description : "Directory with JSON formatted OpenTofu" ,
116
+ workingDir : "test-fixtures/dir-with-tofu-json" ,
117
+ valid : true ,
118
+ },
119
+ {
120
+ description : "Directory with JSON formatted Terraform and OpenTofu" ,
121
+ workingDir : "test-fixtures/dir-with-terraform-and-tofu-json" ,
122
+ valid : true ,
123
+ },
124
+ {
125
+ description : "Directory with no Terraform or OpenTofu" ,
106
126
workingDir : "test-fixtures/dir-with-no-terraform" ,
107
127
valid : false ,
108
128
},
You can’t perform that action at this time.
0 commit comments