From 7f0b8056d7649dc609da74def2c54f1e3801b21a Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Mon, 13 Aug 2018 21:09:20 -0400 Subject: [PATCH] m: add CfgSource and use it in all current cmds --- cmd/totp-proxy/main.go | 2 +- m/m.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/totp-proxy/main.go b/cmd/totp-proxy/main.go index 1283da6..e153601 100644 --- a/cmd/totp-proxy/main.go +++ b/cmd/totp-proxy/main.go @@ -104,7 +104,7 @@ func main() { }) mhttp.CfgServer(cfg, authHandler) - if err := cfg.StartRun(context.Background(), new(mcfg.SourceCLI)); err != nil { + if err := cfg.StartRun(context.Background(), m.CfgSource()); err != nil { mlog.Fatal("error during startup", mlog.ErrKV(err)) } select {} diff --git a/m/m.go b/m/m.go index c223b28..e52ad2d 100644 --- a/m/m.go +++ b/m/m.go @@ -11,6 +11,15 @@ import ( "github.com/mediocregopher/mediocre-go-lib/mlog" ) +// CfgSource returns an mcfg.Source which takes in configuration info from the +// environment and from the CLI. +func CfgSource() mcfg.Source { + return mcfg.Sources{ + mcfg.SourceEnv{}, + mcfg.SourceCLI{}, + } +} + // TODO this isn't going to work. At some point there will be something like // mhttp which will have some glue code for it in here, but then something // within it which logs (like the http server), and then there'll be an import