mysqld_exporter icon indicating copy to clipboard operation
mysqld_exporter copied to clipboard

Allow comment characters within configuration values when using my.cnf

Open buzztaiki opened this issue 2 years ago • 7 comments

This PR will fix https://github.com/prometheus/mysqld_exporter/issues/376

I've configured SpaceBeforeInlineComment option to allow comment characters within values. see https://github.com/go-ini/ini/blob/b2f570e5b5b844226bbefe6fb521d891f529a951/ini.go#L97-L101

buzztaiki avatar Sep 12 '23 15:09 buzztaiki

What about passwords with # or ; in them?

SuperQ avatar Sep 12 '23 16:09 SuperQ

Oh, I see, this is to allow this. Wouldn't quotes used be a safer way to handle this?

SuperQ avatar Sep 12 '23 16:09 SuperQ

EDIT: It turns out you can escape comment chars by using backticks or triple quotes.

~I stumbled upon this PR because I hit the same issue. Even when quoted, comment characters are still interpreted as the beginning of comments.~

~Here's a quick playspace demonstrating that using the same ini package: https://goplay.space/#dAkouM7WJ1T~

patrickeasters avatar Sep 18 '23 19:09 patrickeasters

@patrickeasters Thanks for digging into the quoting. Perhaps we should update the README docs to recommend backtick quoting of passwords.

SuperQ avatar Sep 18 '23 21:09 SuperQ

I would also be fine with simply flipping IgnoreInlineComment: true.

SuperQ avatar Sep 18 '23 21:09 SuperQ

Either of those sound better than the rabbit hole of reading docs of mysqld_exporter's dependencies and cursing the inconsistency of INI parsers. 😄

Updating the README is of course the safest, but I don't imagine a ton of folks using inline comments in these INI files either.

patrickeasters avatar Sep 19 '23 02:09 patrickeasters

This needs a DCO sign-off. You can use git commit -s --amend to add it.

SuperQ avatar Sep 19 '23 05:09 SuperQ