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
Fixes for configuration file support for cli options #257
Conversation
A user may pass an unknown value in via the configuration file. https://bugzilla.redhat.com/show_bug.cgi?id=2079698 Signed-off-by: Rob Crittenden <rcritten@redhat.com>
ConfigParser allows both = and : as a delimiter. Limit to just = to match the configuration file man page. Don't allow empty values in options in the config file. https://bugzilla.redhat.com/show_bug.cgi?id=2079739 Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Since the configuration file allows options to be set we need to evaluate them after the merge. Leaving version handling pre-config load since it makes no sense within the config file. https://bugzilla.redhat.com/show_bug.cgi?id=2079861 Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Hi @rcritten
My testing detected other issues, not related to this PR:
|
Thanks for the review. I added a function to try to convert the configuration strings into native python data types. |
"true", | ||
"false", | ||
): | ||
return value.lower() == 'true' |
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.
With the convert_string function, debug=other
still triggers the debug mode. The boolean options should probably be handled separately (with something like if key in ('debug', 'verbose'):...
)
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.
I was trying to avoid that because I can't control what other users of healthcheck may configure as variables (pki has its own pki-healthcheck command). I suppose I can add it for the currently known booleans. I don't think I have access to the argparse options directly at this point so I can't auto-detect the type.
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.
Even with access to argparse I can't find a way to get the expected types so I added a list of known booleans and integers.
When loading options from the configuration file they will all be strings. This breaks existing boolean checks (if <something>) and some assumptions about integer types (e.g. timeout, indent). So try to detect the data type, defaulting to remain as a string. Also hardcode some type validation for known keys to prevent things like debug=foo (which would evaluate to True). https://bugzilla.redhat.com/show_bug.cgi?id=2079861 Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Hi @rcritten
|
Thanks for the careful review. |
Three small fixes to allowing the configuration file to set command-line options discovered by QE during review process