Skip to content

Commit f46a48b

Browse files
committed
Attempt looking up config file in .config folder
The updated order of trying to look up for .terraform-docs.yml config file, now, is: 1. root of module directory 2. `.config/` folder at root of module directory 3. current directory 4. `.config/` folder at current directory 5. `$HOME/.tfdocs.d/` Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
1 parent 59a9f4e commit f46a48b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

docs/user-guide/configuration.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ $ tree
3939
$ terraform-docs -c .tfdocs-config.yml .
4040
```
4141

42-
As of `v0.13.0`, the order for looking for config file is:
42+
As of `v0.13.0`, the order for looking for config file is *(2 and 4 were added
43+
in `v0.15.0`)*:
4344

4445
1. root of module directory
46+
1. `.config/` folder at root of module directory
4547
1. current directory
48+
1. `.config/` folder at current directory
4649
1. `$HOME/.tfdocs.d/`
4750

4851
if `.terraform-docs.yml` is found in any of the folders above, that will take

internal/cli/run.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ func PreRunEFunc(config *Config) func(*cobra.Command, []string) error { //nolint
6161
v.SetConfigType("yml")
6262
}
6363

64-
v.AddConfigPath(args[0]) // first look at module root
65-
v.AddConfigPath(".") // then current directory
66-
v.AddConfigPath("$HOME/.tfdocs.d") // and finally $HOME/.tfdocs.d/
64+
v.AddConfigPath(args[0]) // first look at module root
65+
v.AddConfigPath(args[0] + "/.config") // then .config/ folder at module root
66+
v.AddConfigPath(".") // then current directory
67+
v.AddConfigPath(".config") // then .config/ folder at current directory
68+
v.AddConfigPath("$HOME/.tfdocs.d") // and finally $HOME/.tfdocs.d/
6769

6870
if err := v.ReadInConfig(); err != nil {
6971
var perr *os.PathError

0 commit comments

Comments
 (0)