From 23292e5cad0ce3fad0ed82342bfede3f3fb6c77f Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 1 Mar 2018 19:33:22 +0100 Subject: [PATCH] Fix determining beta value through configuration --- cdist/argparse.py | 3 +-- cdist/configuration.py | 7 ++++++- docs/changelog | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cdist/argparse.py b/cdist/argparse.py index 66a87094..fbe2bba6 100644 --- a/cdist/argparse.py +++ b/cdist/argparse.py @@ -126,8 +126,7 @@ def get_parsers(): parser['beta'].add_argument( '-b', '--beta', help=('Enable beta functionality. '), - action='store_true', dest='beta', - default=False) + action='store_true', dest='beta', default=None) # Main subcommand parser parser['main'] = argparse.ArgumentParser( diff --git a/cdist/configuration.py b/cdist/configuration.py index 2a253e7f..674551b8 100644 --- a/cdist/configuration.py +++ b/cdist/configuration.py @@ -409,7 +409,12 @@ class Configuration(metaclass=Singleton): if option in args: dst_opt = self.ARG_OPTION_MAPPING[option] option_object = self.CONFIG_FILE_OPTIONS['GLOBAL'][dst_opt] - if args[option] or isinstance(option_object, BooleanOption): + # If option is in args. + # Also if it is boolean but only if not None - this allows + # False to override True. + if (args[option] or + (isinstance(option_object, BooleanOption) and + args[option] is not None)): d[dst_opt] = args[option] return d diff --git a/docs/changelog b/docs/changelog index 0bf77a31..fadad32f 100644 --- a/docs/changelog +++ b/docs/changelog @@ -10,6 +10,7 @@ next: * Core: Fix non-existent manifest non graceful handling (Darko Poljak) * Core: Fix main and inventory parent argparse options (Darko Poljak) * Core: Fix lost error info with parallel jobs (option -j) (Darko Poljak) + * Core: Fix determining beta value through configuration (Darko Poljak) 4.8.0: 2018-02-14 * Core: Skip empty lines in parameter files (Darko Poljak)