@@ -15,15 +15,17 @@ const (
15
15
TemplateArchiveLimit = 1 << 20
16
16
)
17
17
18
- func dirHasExt (dir string , ext string ) (bool , error ) {
18
+ func dirHasExt (dir string , exts ... string ) (bool , error ) {
19
19
dirEnts , err := os .ReadDir (dir )
20
20
if err != nil {
21
21
return false , err
22
22
}
23
23
24
24
for _ , fi := range dirEnts {
25
- if strings .HasSuffix (fi .Name (), ext ) {
26
- return true , nil
25
+ for _ , ext := range exts {
26
+ if strings .HasSuffix (fi .Name (), ext ) {
27
+ return true , nil
28
+ }
27
29
}
28
30
}
29
31
@@ -35,8 +37,8 @@ func Tar(w io.Writer, directory string, limit int64) error {
35
37
tarWriter := tar .NewWriter (w )
36
38
totalSize := int64 (0 )
37
39
38
- const tfExt = ".tf"
39
- hasTf , err := dirHasExt (directory , tfExt )
40
+ tfExts := [] string { ".tf" , ".tf.json" }
41
+ hasTf , err := dirHasExt (directory , tfExts ... )
40
42
if err != nil {
41
43
return err
42
44
}
@@ -50,7 +52,7 @@ func Tar(w io.Writer, directory string, limit int64) error {
50
52
// useless.
51
53
return xerrors .Errorf (
52
54
"%s is not a valid template since it has no %s files" ,
53
- absPath , tfExt ,
55
+ absPath , tfExts ,
54
56
)
55
57
}
56
58
0 commit comments