command: put the modules in ".terraform/modules"
This also fixes a case where tests wre leaking files
This commit is contained in:
parent
9ccc8aebf1
commit
5f6fe1f931
|
@ -19,6 +19,10 @@ const DefaultVarsFilename = "terraform.tfvars"
|
|||
// DefaultBackupExtention is added to the state file to form the path
|
||||
const DefaultBackupExtention = ".backup"
|
||||
|
||||
// DefaultDataDirectory is the directory where local state is stored
|
||||
// by default.
|
||||
const DefaultDataDirectory = ".terraform"
|
||||
|
||||
func validateContext(ctx *terraform.Context, ui cli.Ui) bool {
|
||||
if ws, es := ctx.Validate(); len(ws) > 0 || len(es) > 0 {
|
||||
ui.Output(
|
||||
|
|
|
@ -14,6 +14,7 @@ func TestGet(t *testing.T) {
|
|||
Meta: Meta{
|
||||
ContextOpts: testCtxConfig(testProvider()),
|
||||
Ui: ui,
|
||||
dataDir: tempDir(t),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -39,6 +40,7 @@ func TestGet_multipleArgs(t *testing.T) {
|
|||
Meta: Meta{
|
||||
ContextOpts: testCtxConfig(testProvider()),
|
||||
Ui: ui,
|
||||
dataDir: tempDir(t),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -66,6 +68,7 @@ func TestGet_noArgs(t *testing.T) {
|
|||
Meta: Meta{
|
||||
ContextOpts: testCtxConfig(testProvider()),
|
||||
Ui: ui,
|
||||
dataDir: tempDir(t),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -89,6 +92,7 @@ func TestGet_update(t *testing.T) {
|
|||
Meta: Meta{
|
||||
ContextOpts: testCtxConfig(testProvider()),
|
||||
Ui: ui,
|
||||
dataDir: tempDir(t),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@ type Meta struct {
|
|||
// This can be set by the command itself to provide extra hooks.
|
||||
extraHooks []terraform.Hook
|
||||
|
||||
// This can be set by tests to change some directories
|
||||
dataDir string
|
||||
|
||||
// Variables for the context (private)
|
||||
autoKey string
|
||||
autoVariables map[string]string
|
||||
|
@ -95,7 +98,12 @@ func (m *Meta) Context(copts contextOpts) (*terraform.Context, bool, error) {
|
|||
if err != nil {
|
||||
return nil, false, fmt.Errorf("Error loading config: %s", err)
|
||||
}
|
||||
err = mod.Load(m.moduleStorage(copts.Path), copts.GetMode)
|
||||
|
||||
dataDir := DefaultDataDirectory
|
||||
if m.dataDir != "" {
|
||||
dataDir = m.dataDir
|
||||
}
|
||||
err = mod.Load(m.moduleStorage(dataDir), copts.GetMode)
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("Error downloading modules: %s", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue