From 96db88b7d0c58bab5e145af69d0b011b5ed8661e Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 11 Jan 2019 17:44:53 -0500 Subject: [PATCH] mcfg: allow Source param to Populate to be nil --- mcfg/mcfg.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mcfg/mcfg.go b/mcfg/mcfg.go index 24f3c6d..152e3d3 100644 --- a/mcfg/mcfg.go +++ b/mcfg/mcfg.go @@ -76,6 +76,10 @@ func collectParams(ctx mctx.Context) []Param { } func populate(params []Param, src Source) error { + if src == nil { + src = SourceMap{} + } + pvs, err := src.Parse(params) if err != nil { 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 // 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 { return populate(collectParams(ctx), src) }