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
|
// Load the root module
|
||||||
mod, err := module.NewTreeModule("", copts.Path)
|
var mod *module.Tree
|
||||||
if err != nil {
|
if copts.Path != "" {
|
||||||
return nil, false, fmt.Errorf("Error loading config: %s", err)
|
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)
|
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}
|
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
|
// 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 directory and gives it a specific name. Use a blank name "" to specify
|
||||||
// the root module.
|
// the root module.
|
||||||
|
|
Loading…
Reference in New Issue