From 3af9e3904392c0a2b6e1cf9020805f0a14d968d7 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 6 Jun 2022 10:57:28 +0200 Subject: [PATCH] cmd_runner: deprecate fmt as the name for the format class (#4777) (#4784) * cmd_runner: deprecate fmt as the name for the format class * added changelog fragment * fixing the deprecation comment (cherry picked from commit 2d38c8d892acd69ae71024fad3c99aecb68c8220) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- .../fragments/4777-cmd-runner-deprecate-fmt.yaml | 2 ++ plugins/module_utils/cmd_runner.py | 10 +++++++++- plugins/module_utils/gconftool2.py | 2 +- .../integration/targets/cmd_runner/library/cmd_echo.py | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/4777-cmd-runner-deprecate-fmt.yaml diff --git a/changelogs/fragments/4777-cmd-runner-deprecate-fmt.yaml b/changelogs/fragments/4777-cmd-runner-deprecate-fmt.yaml new file mode 100644 index 0000000000..6057cf38e8 --- /dev/null +++ b/changelogs/fragments/4777-cmd-runner-deprecate-fmt.yaml @@ -0,0 +1,2 @@ +deprecated_features: + - cmd_runner module utils - deprecated ``fmt`` in favour of ``cmd_runner_fmt`` as the parameter format object (https://github.com/ansible-collections/community.general/pull/4777). diff --git a/plugins/module_utils/cmd_runner.py b/plugins/module_utils/cmd_runner.py index d154dbb7ee..7d6a690224 100644 --- a/plugins/module_utils/cmd_runner.py +++ b/plugins/module_utils/cmd_runner.py @@ -294,4 +294,12 @@ class _CmdRunnerContext(object): return False -fmt = _Format() +cmd_runner_fmt = _Format() + +# +# The fmt form is deprecated and will be removed in community.general 7.0.0 +# Please use: +# cmd_runner_fmt +# Or, to retain the same effect, use: +# from ansible_collections.community.general.plugins.module_utils.cmd_runner import cmd_runner_fmt as fmt +fmt = cmd_runner_fmt diff --git a/plugins/module_utils/gconftool2.py b/plugins/module_utils/gconftool2.py index df9608fb30..f4ee34325d 100644 --- a/plugins/module_utils/gconftool2.py +++ b/plugins/module_utils/gconftool2.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, fmt +from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt def gconftool2_runner(module, **kwargs): diff --git a/tests/integration/targets/cmd_runner/library/cmd_echo.py b/tests/integration/targets/cmd_runner/library/cmd_echo.py index 4b9cb8b547..4fd32a7ac6 100644 --- a/tests/integration/targets/cmd_runner/library/cmd_echo.py +++ b/tests/integration/targets/cmd_runner/library/cmd_echo.py @@ -14,7 +14,7 @@ EXAMPLES = "" RETURN = "" from ansible.module_utils.basic import AnsibleModule -from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, fmt +from ansible_collections.community.general.plugins.module_utils.cmd_runner import CmdRunner, cmd_runner_fmt as fmt def main():