mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
command: add DataDir
This commit is contained in:
parent
cdde9149ff
commit
c4dc9af120
@ -138,11 +138,7 @@ func (m *Meta) Context(copts contextOpts) (*terraform.Context, bool, error) {
|
|||||||
return nil, false, fmt.Errorf("Error loading config: %s", err)
|
return nil, false, fmt.Errorf("Error loading config: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dataDir := DefaultDataDirectory
|
err = mod.Load(m.moduleStorage(m.DataDir()), copts.GetMode)
|
||||||
if m.dataDir != "" {
|
|
||||||
dataDir = m.dataDir
|
|
||||||
}
|
|
||||||
err = mod.Load(m.moduleStorage(dataDir), copts.GetMode)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, fmt.Errorf("Error downloading modules: %s", err)
|
return nil, false, fmt.Errorf("Error downloading modules: %s", err)
|
||||||
}
|
}
|
||||||
@ -153,6 +149,16 @@ func (m *Meta) Context(copts contextOpts) (*terraform.Context, bool, error) {
|
|||||||
return ctx, false, nil
|
return ctx, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DataDir returns the directory where local data will be stored.
|
||||||
|
func (m *Meta) DataDir() string {
|
||||||
|
dataDir := DefaultDataDirectory
|
||||||
|
if m.dataDir != "" {
|
||||||
|
dataDir = m.dataDir
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataDir
|
||||||
|
}
|
||||||
|
|
||||||
// InputMode returns the type of input we should ask for in the form of
|
// InputMode returns the type of input we should ask for in the form of
|
||||||
// terraform.InputMode which is passed directly to Context.Input.
|
// terraform.InputMode which is passed directly to Context.Input.
|
||||||
func (m *Meta) InputMode() terraform.InputMode {
|
func (m *Meta) InputMode() terraform.InputMode {
|
||||||
@ -205,7 +211,7 @@ func (m *Meta) StateOpts() *StateOpts {
|
|||||||
if localPath == "" {
|
if localPath == "" {
|
||||||
localPath = DefaultStateFilename
|
localPath = DefaultStateFilename
|
||||||
}
|
}
|
||||||
remotePath := filepath.Join(DefaultDataDir, DefaultStateFilename)
|
remotePath := filepath.Join(m.DataDir(), DefaultStateFilename)
|
||||||
|
|
||||||
return &StateOpts{
|
return &StateOpts{
|
||||||
LocalPath: localPath,
|
LocalPath: localPath,
|
||||||
|
Loading…
Reference in New Issue
Block a user