From cc501feeeb121a0f02d7d32f28c348458d085ffe Mon Sep 17 00:00:00 2001 From: Branden J Brown Date: Tue, 19 Nov 2024 15:03:20 -0500 Subject: [PATCH] robot: report references to missing env vars in config Fixes #89. --- config.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index dc14923..ac5cb9e 100644 --- a/config.go +++ b/config.go @@ -43,7 +43,13 @@ func Load(ctx context.Context, r io.Reader) (*Config, *toml.MetaData, error) { if err != nil { return nil, nil, fmt.Errorf("couldn't decode config: %w", err) } - expandcfg(&cfg, os.Getenv) + expandcfg(&cfg, func(s string) string { + v, ok := os.LookupEnv(s) + if !ok { + slog.ErrorContext(ctx, "config refers to missing environment variable", slog.String("variable", s)) + } + return v + }) return &cfg, &md, nil }