File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,6 +41,11 @@ func ConfigFile() (string, error) {
4141 return configFile ()
4242}
4343
44+ // ConfigDir returns the configuration directory for Terraform.
45+ func ConfigDir () (string , error ) {
46+ return configDir ()
47+ }
48+
4449// LoadConfig loads the CLI configuration from ".terraformrc" files.
4550func LoadConfig (path string ) (* Config , error ) {
4651 // Read the HCL file and prepare for parsing
@@ -76,6 +81,17 @@ func (c *Config) Discover() error {
7681 return err
7782 }
7883
84+ // Look in the plugins directory. This will override any found
85+ // in the current directory.
86+ dir , err := ConfigDir ()
87+ if err != nil {
88+ log .Printf ("[ERR] Error loading config directory: %s" , err )
89+ } else {
90+ if err := c .discover (filepath .Join (dir , "plugins" )); err != nil {
91+ return err
92+ }
93+ }
94+
7995 // Next, look in the same directory as the executable. Any conflicts
8096 // will overwrite those found in our current directory.
8197 exePath , err := osext .Executable ()
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import (
1313)
1414
1515func configFile () (string , error ) {
16- dir , err := configDir ()
16+ dir , err := homeDir ()
1717 if err != nil {
1818 return "" , err
1919 }
@@ -22,6 +22,15 @@ func configFile() (string, error) {
2222}
2323
2424func configDir () (string , error ) {
25+ dir , err := homeDir ()
26+ if err != nil {
27+ return "" , err
28+ }
29+
30+ return filepath .Join (dir , ".terraform.d" ), nil
31+ }
32+
33+ func homeDir () (string , error ) {
2534 // First prefer the HOME environmental variable
2635 if home := os .Getenv ("HOME" ); home != "" {
2736 log .Printf ("Detected home directory from env var: %s" , home )
Original file line number Diff line number Diff line change 1616const CSIDL_APPDATA = 26
1717
1818func configFile () (string , error ) {
19- dir , err := configDir ()
19+ dir , err := homeDir ()
2020 if err != nil {
2121 return "" , err
2222 }
@@ -25,6 +25,15 @@ func configFile() (string, error) {
2525}
2626
2727func configDir () (string , error ) {
28+ dir , err := homeDir ()
29+ if err != nil {
30+ return "" , err
31+ }
32+
33+ return filepath .Join (dir , "terraform.d" ), nil
34+ }
35+
36+ func homeDir () (string , error ) {
2837 b := make ([]uint16 , syscall .MAX_PATH )
2938
3039 // See: http://msdn.microsoft.com/en-us/library/windows/desktop/bb762181(v=vs.85).aspx
You can’t perform that action at this time.
0 commit comments