From 64881323e89d6d9b96865a5fa6f2150b826683db Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 17 May 2024 16:45:47 +0200 Subject: feat: error on non-matching configuration entries --- internal/config/config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index 88bc006..6837ea7 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -191,12 +191,17 @@ func GetConfig(filename string) (*Config, error) { defer f.Close() dec := toml.NewDecoder(f) + dec.DisallowUnknownFields() err = dec.Decode(&config) if err != nil { var tomlError *toml.DecodeError if errors.As(err, &tomlError) { return nil, errors.WithMessage(err, tomlError.Error()) } + var missingConfigError *toml.StrictMissingError + if errors.As(err, &missingConfigError) { + return nil, errors.Errorf("unexpected config: %s", missingConfigError.String()) + } return nil, errors.Wrap(err, "config error") } -- cgit 1.4.1