configs: NewEmptyConfig function

This is useful for creating a valid placeholder configuration, but not
much else. Most callers should use BuildConfig to build a configuration
that actually has something in it.
This commit is contained in:
Martin Atkins 2018-04-06 13:57:21 -07:00
parent c07b0a7806
commit 2eba023537
1 changed files with 11 additions and 0 deletions

View File

@ -73,6 +73,17 @@ type Config struct {
Version *version.Version
}
// NewEmptyConfig constructs a single-node configuration tree with an empty
// root module. This is generally a pretty useless thing to do, so most callers
// should instead use BuildConfig.
func NewEmptyConfig() *Config {
ret := &Config{}
ret.Root = ret
ret.Children = make(map[string]*Config)
ret.Module = &Module{}
return ret
}
// Depth returns the number of "hops" the receiver is from the root of its
// module tree, with the root module having a depth of zero.
func (c *Config) Depth() int {