mcfg: allow Source param to Populate to be nil

This commit is contained in:
Brian Picciano 2019-01-11 17:44:53 -05:00
parent 57c400a151
commit 96db88b7d0

View File

@ -76,6 +76,10 @@ func collectParams(ctx mctx.Context) []Param {
} }
func populate(params []Param, src Source) error { func populate(params []Param, src Source) error {
if src == nil {
src = SourceMap{}
}
pvs, err := src.Parse(params) pvs, err := src.Parse(params)
if err != nil { if err != nil {
return err return err
@ -108,6 +112,9 @@ func populate(params []Param, src Source) error {
// Populate uses the Source to populate the values of all Params which were // Populate uses the Source to populate the values of all Params which were
// added to the given mctx.Context, and all of its children. // added to the given mctx.Context, and all of its children.
//
// Source may be nil to indicate that no configuration is provided. Only default
// values will be used, and if any paramaters are required this will error.
func Populate(ctx mctx.Context, src Source) error { func Populate(ctx mctx.Context, src Source) error {
return populate(collectParams(ctx), src) return populate(collectParams(ctx), src)
} }