File tree 3 files changed +20
-19
lines changed
3 files changed +20
-19
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -17,9 +17,21 @@ func (mf ModFilename) IsJSON() bool {
17
17
}
18
18
19
19
func IsModuleFilename (name string ) bool {
20
- return (strings .HasSuffix (name , ".tf" ) ||
21
- strings .HasSuffix (name , ".tf.json" )) &&
22
- ! isIgnoredFile (name )
20
+ if isIgnoredFile (name ) {
21
+ // See https://github.com/hashicorp/terraform/blob/d35bc05/internal/configs/parser_config_dir.go#L107
22
+ return false
23
+ }
24
+
25
+ return strings .HasSuffix (name , ".tf" ) ||
26
+ strings .HasSuffix (name , ".tf.json" )
27
+ }
28
+
29
+ // isIgnoredFile returns true if the given filename (which must not have a
30
+ // directory path ahead of it) should be ignored as e.g. an editor swap file.
31
+ func isIgnoredFile (name string ) bool {
32
+ return strings .HasPrefix (name , "." ) || // Unix-like hidden files
33
+ strings .HasSuffix (name , "~" ) || // vim
34
+ strings .HasPrefix (name , "#" ) && strings .HasSuffix (name , "#" ) // emacs
23
35
}
24
36
25
37
type ModFiles map [ModFilename ]* hcl.File
Original file line number Diff line number Diff line change @@ -16,9 +16,11 @@ func NewVarsFilename(name string) (VarsFilename, bool) {
16
16
}
17
17
18
18
func IsVarsFilename (name string ) bool {
19
- return (strings .HasSuffix (name , ".tfvars" ) ||
20
- strings .HasSuffix (name , ".tfvars.json" )) &&
21
- ! isIgnoredFile (name )
19
+ // even files which are normally ignored/hidden,
20
+ // such as .foo.tfvars (with leading .) are accepted here
21
+ // see https://github.com/hashicorp/terraform/blob/77e6b62/internal/command/meta.go#L734-L738
22
+ return strings .HasSuffix (name , ".tfvars" ) ||
23
+ strings .HasSuffix (name , ".tfvars.json" )
22
24
}
23
25
24
26
func (vf VarsFilename ) String () string {
You can’t perform that action at this time.
0 commit comments