mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
command: Context buliding allows empty module trees
This commit is contained in:
parent
182a8a28c0
commit
3c9a92e04a
@ -146,9 +146,14 @@ func (m *Meta) Context(copts contextOpts) (*terraform.Context, bool, error) {
|
||||
}
|
||||
|
||||
// Load the root module
|
||||
mod, err := module.NewTreeModule("", copts.Path)
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("Error loading config: %s", err)
|
||||
var mod *module.Tree
|
||||
if copts.Path != "" {
|
||||
mod, err = module.NewTreeModule("", copts.Path)
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("Error loading config: %s", err)
|
||||
}
|
||||
} else {
|
||||
mod = module.NewEmptyTree()
|
||||
}
|
||||
|
||||
err = mod.Load(m.moduleStorage(m.DataDir()), copts.GetMode)
|
||||
|
@ -33,6 +33,11 @@ func NewTree(name string, c *config.Config) *Tree {
|
||||
return &Tree{config: c, name: name}
|
||||
}
|
||||
|
||||
// NewEmptyTree returns a new tree that is empty (contains no configuration).
|
||||
func NewEmptyTree() *Tree {
|
||||
return &Tree{config: &config.Config{}}
|
||||
}
|
||||
|
||||
// NewTreeModule is like NewTree except it parses the configuration in
|
||||
// the directory and gives it a specific name. Use a blank name "" to specify
|
||||
// the root module.
|
||||
|
Loading…
Reference in New Issue
Block a user