Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UnmarshalStrict for config file to catch config errors #54

Merged
merged 1 commit into from
Mar 14, 2021

Conversation

chr4
Copy link
Contributor

@chr4 chr4 commented Mar 14, 2021

This uses StrictUnmarshal() when parsing the config, which should make it fail when unknown config attributes are used.

This would've helped me spot #52, so I thought it might be worth a consideration.

Here's the error displayed with an invalid YAML:

fatal   cmd/mqtt2prometheus.go:72       Could not load config   {"error": "yaml: unmarshal errors:\n  line 8: field cache not found in type config.MQTTConfig"}

I've tested this with the other example configs, but not sure if there might be a side effect I'm not catching here.

@hikhvar
Copy link
Owner

hikhvar commented Mar 14, 2021

Hey,
thank you for this valuable contribution! I think this will break nothing.

@hikhvar hikhvar merged commit 3b436b2 into hikhvar:master Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants