mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Consolidate boolean/mk_boolean conversion functions into a single location
Consolidate the module_utils, constants, and config functions that convert values into booleans into a single function in module_utils. Port code to use the module_utils.validate.convert_bool.boolean function isntead of mk_boolean.
This commit is contained in:
parent
f9c60e1a82
commit
ff22528b07
30 changed files with 433 additions and 102 deletions
|
@ -41,6 +41,7 @@ from ansible.cli import CLI
|
|||
from ansible.errors import AnsibleError
|
||||
from ansible.executor.task_queue_manager import TaskQueueManager
|
||||
from ansible.module_utils._text import to_native, to_text
|
||||
from ansible.module_utils.parsing.convert_bool import boolean
|
||||
from ansible.parsing.splitter import parse_kv
|
||||
from ansible.playbook.play import Play
|
||||
from ansible.plugins import module_loader
|
||||
|
@ -295,7 +296,7 @@ class ConsoleCLI(CLI, cmd.Cmd):
|
|||
def do_become(self, arg):
|
||||
"""Toggle whether plays run with become"""
|
||||
if arg:
|
||||
self.options.become = C.mk_boolean(arg)
|
||||
self.options.become = boolean(arg, strict=False)
|
||||
display.v("become changed to %s" % self.options.become)
|
||||
self.set_prompt()
|
||||
else:
|
||||
|
@ -329,7 +330,7 @@ class ConsoleCLI(CLI, cmd.Cmd):
|
|||
def do_check(self, arg):
|
||||
"""Toggle whether plays run with check mode"""
|
||||
if arg:
|
||||
self.options.check = C.mk_boolean(arg)
|
||||
self.options.check = boolean(arg, strict=False)
|
||||
display.v("check mode changed to %s" % self.options.check)
|
||||
else:
|
||||
display.display("Please specify check mode value, e.g. `check yes`")
|
||||
|
@ -337,7 +338,7 @@ class ConsoleCLI(CLI, cmd.Cmd):
|
|||
def do_diff(self, arg):
|
||||
"""Toggle whether plays run with diff"""
|
||||
if arg:
|
||||
self.options.diff = C.mk_boolean(arg)
|
||||
self.options.diff = boolean(arg, strict=False)
|
||||
display.v("diff mode changed to %s" % self.options.diff)
|
||||
else:
|
||||
display.display("Please specify a diff value , e.g. `diff yes`")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue