about summary refs log tree commit diff stats
path: root/internal/config
diff options
context:
space:
mode:
authorAlan Pearce2024-05-17 16:45:47 +0200
committerAlan Pearce2024-05-17 16:45:47 +0200
commit64881323e89d6d9b96865a5fa6f2150b826683db (patch)
tree6560eea49d001a73620474d3f2e9fe43933bf66c /internal/config
parent8805c25adece20e4bee90faf0052804a3bfbab32 (diff)
downloadsearchix-64881323e89d6d9b96865a5fa6f2150b826683db.tar.lz
searchix-64881323e89d6d9b96865a5fa6f2150b826683db.tar.zst
searchix-64881323e89d6d9b96865a5fa6f2150b826683db.zip
feat: error on non-matching configuration entries
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go5
1 files changed, 5 insertions, 0 deletions
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")
 		}