command: Context buliding allows empty module trees
This commit is contained in:
parent
182a8a28c0
commit
3c9a92e04a
|
@ -146,10 +146,15 @@ func (m *Meta) Context(copts contextOpts) (*terraform.Context, bool, error) {
|
|||
}
|
||||
|
||||
// Load the root module
|
||||
mod, err := module.NewTreeModule("", copts.Path)
|
||||
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)
|
||||
if err != nil {
|
||||
|
|
|
@ -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