Skip to content

Commit

Permalink
robot: report references to missing env vars in config
Browse files Browse the repository at this point in the history
Fixes #89.
  • Loading branch information
zephyrtronium committed Nov 19, 2024
1 parent 35fd063 commit cc501fe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit cc501fe

Please sign in to comment.