mirror of
https://github.com/terraform-docs/terraform-docs.git
synced 2026-03-27 12:58:35 +07:00
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>
This commit is contained in:
@@ -39,10 +39,13 @@ $ tree
|
||||
$ terraform-docs -c .tfdocs-config.yml .
|
||||
```
|
||||
|
||||
As of `v0.13.0`, the order for looking for config file is:
|
||||
As of `v0.13.0`, the order for looking for config file is *(2 and 4 were added
|
||||
in `v0.15.0`)*:
|
||||
|
||||
1. root of module directory
|
||||
1. `.config/` folder at root of module directory
|
||||
1. current directory
|
||||
1. `.config/` folder at current directory
|
||||
1. `$HOME/.tfdocs.d/`
|
||||
|
||||
if `.terraform-docs.yml` is found in any of the folders above, that will take
|
||||
|
||||
@@ -61,9 +61,11 @@ func PreRunEFunc(config *Config) func(*cobra.Command, []string) error { //nolint
|
||||
v.SetConfigType("yml")
|
||||
}
|
||||
|
||||
v.AddConfigPath(args[0]) // first look at module root
|
||||
v.AddConfigPath(".") // then current directory
|
||||
v.AddConfigPath("$HOME/.tfdocs.d") // and finally $HOME/.tfdocs.d/
|
||||
v.AddConfigPath(args[0]) // first look at module root
|
||||
v.AddConfigPath(args[0] + "/.config") // then .config/ folder at module root
|
||||
v.AddConfigPath(".") // then current directory
|
||||
v.AddConfigPath(".config") // then .config/ folder at current directory
|
||||
v.AddConfigPath("$HOME/.tfdocs.d") // and finally $HOME/.tfdocs.d/
|
||||
|
||||
if err := v.ReadInConfig(); err != nil {
|
||||
var perr *os.PathError
|
||||
|
||||
Reference in New Issue
Block a user