-
Notifications
You must be signed in to change notification settings - Fork 91
Improve mackerel-agent configtest
: detect unexpected key
#813
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
Conversation
config/validate.go
Outdated
return nil, fmt.Errorf("failed to test config: %s", err) | ||
} | ||
|
||
var unexpectedKey []string = make([]string, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[may] This might be declared just var unexpectedKey []string
simply.
more better name: unexpectedKeys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed 0554f6b
} | ||
|
||
for k1, v := range config.Plugin { | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a good comment
👍
commands.go
Outdated
|
||
do configtest | ||
*/ | ||
func doConfigtest(fs *flag.FlagSet, argv []string) error { | ||
conf, err := resolveConfig(fs, argv) | ||
if err != nil { | ||
return fmt.Errorf("failed to test config: %s", err) | ||
return fmt.Errorf("\x1b[31m[CRITICAL] failed to test config: %s \x1b[0m", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mackerel-agent runs on Windows, so we had better either to use https://github.com/mattn/go-colorable or https://github.com/fatih/color, or to disable ANSI escape codes except on go:build unix
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed 56a0642
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
part of: #810
example of WARNING
~/desktop/mackerel-agent $ ./build/mackerel-agent configtest -conf=/usr/local/etc/mackerel-agent-sample.conf [WARNING] podfile is unexpected key [WARNING] foobar is unexpected key [WARNING] foobar.command is unexpected key [WARNING] foobar.env.FOO is unexpected key [WARNING] foobar.env is unexpected key [WARNING] plugins.check.first is unexpected key [WARNING] plugins.check.first.command is unexpected key [WARNING] plugin.metric.first is unexpected key [WARNING] plugin.check.first is unexpected key [WARNING] plugin.check.second is unexpected key [WARNING] plugin.foo.bar is unexpected key
example of CRITICAL