Skip to content

Commit

Permalink
Unify command-line options and configuration
Browse files Browse the repository at this point in the history
This adds command-line options to the configuration, but not vice-versa.
It will allow for greater flexibility when running this automatically
without having to change any scripting.

https://bugzilla.redhat.com/show_bug.cgi?id=1872467

Signed-off-by: Rob Crittenden <[email protected]>
  • Loading branch information
rcritten committed Sep 17, 2021
1 parent 0bdd0f8 commit 00f23a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion man/man5/ipahealthcheck.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ The following options are relevant for the server:
.TP
.B cert_expiration_days\fR
The number of days left before a certificate expires to start displaying a warning. The default is 28.
.TP
All command\-line options may be include in the configuration file. Dashes must be converted to underscore for the configuration file, e.g. \-\-output\-type becomes output_type. All options, including those that don't make sense in a config file, like \-\-list\-sources, are allowed. Let the buyer beware.
.TP
The purpose of allowing command\-line options to be in the configuration file is for automation without having to tweak the automation script. For example, if you want the default output type to be human for the systemd timer automated runs, settting output_type=human in the configuration file will do this. Note that changing the default location of log files is not possible because the shipped timer executable has \-\-output\-file on the command\-line so will override the configuration file.
.TP
Options are first loaded from the configuration file and command\-line options are merged in, with the command\-line option having preference. The command\-line take precedence except where this is not possible. An example is if all=True is set in the configuration file, and the command\-line contains \-\-failures\-only, then only failures will be displayed.
.TP
Options that don't make sense for the configuration file include \-\-list\-sources and \-\-input\-file.
.SH "FILES"
.TP
.I /etc/ipahealthcheck/ipahealthcheck.conf
Expand All @@ -49,4 +57,4 @@ configuration file
cert_expiration_days=7

.SH "SEE ALSO"
.BR ipa-healthcheck (8)
.BR ipa\-healthcheck (8)
7 changes: 6 additions & 1 deletion src/ipahealthcheck/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ def run_healthcheck(self):
add_output_options(self.parser, self.output_registry)
self.add_options()
options = parse_options(self.parser)
self.options = options

if options.version:
for registry in self.entry_points:
Expand Down Expand Up @@ -294,6 +293,12 @@ def run_healthcheck(self):
if config is None:
return 1

# Unify config and options. One will be deprecated in the
# future. This way all cli options can be set in config instead.
config.merge(vars(options))
self.options = config
options = config

# pylint: disable=assignment-from-none
rval = self.pre_check()
# pylint: enable=assignment-from-none
Expand Down

0 comments on commit 00f23a6

Please sign in to comment.