From 27fd8e4dc6a45c81b418647c1b8bd97a52ee8755 Mon Sep 17 00:00:00 2001 From: Alexander Bethke Date: Fri, 7 Dec 2018 17:38:42 +0100 Subject: [PATCH] Fix two regressions in flatpak and flatpak_remote modules (#49651) * Fix python 3 compatibility in flatpak_remote module * Fix flatpak module for recent versions of flatpak * Add reminder for contributors to run integration tests manually There has been several Python version compatibility regressions introduced into the module which could have been avoided by the integration tests. --- lib/ansible/modules/packaging/os/flatpak.py | 23 ++++++++++++++++++- .../modules/packaging/os/flatpak_remote.py | 23 ++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/packaging/os/flatpak.py b/lib/ansible/modules/packaging/os/flatpak.py index d4beae373f..49efc35ee9 100644 --- a/lib/ansible/modules/packaging/os/flatpak.py +++ b/lib/ansible/modules/packaging/os/flatpak.py @@ -6,6 +6,27 @@ # Copyright: (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +# ATTENTION CONTRIBUTORS! +# +# TL;DR: Run this module's integration tests manually before opening a pull request +# +# Long explanation: +# The integration tests for this module are currently NOT run on the Ansible project's continuous +# delivery pipeline. So please: When you make changes to this module, make sure that you run the +# included integration tests manually for both Python 2 and Python 3: +# +# Python 2: +# ansible-test integration -v --docker fedora28 --docker-privileged --allow-unsupported --python 2.7 flatpak +# Python 3: +# ansible-test integration -v --docker fedora28 --docker-privileged --allow-unsupported --python 3.6 flatpak +# +# Because of external dependencies, the current integration tests are somewhat too slow and brittle +# to be included right now. I have plans to rewrite the integration tests based on a local flatpak +# repository so that they can be included into the normal CI pipeline. +# //oolongbrothers + + from __future__ import (absolute_import, division, print_function) __metaclass__ = type @@ -145,7 +166,7 @@ def uninstall_flat(module, binary, name, method): """Remove an existing flatpak.""" global result installed_flat_name = _match_installed_flat_name(module, binary, name, method) - command = "{0} uninstall --{1} {2}".format(binary, method, installed_flat_name) + command = "{0} uninstall -y --{1} {2}".format(binary, method, installed_flat_name) _flatpak_command(module, module.check_mode, command) result['changed'] = True diff --git a/lib/ansible/modules/packaging/os/flatpak_remote.py b/lib/ansible/modules/packaging/os/flatpak_remote.py index 7422c461ca..508af3c927 100644 --- a/lib/ansible/modules/packaging/os/flatpak_remote.py +++ b/lib/ansible/modules/packaging/os/flatpak_remote.py @@ -6,6 +6,27 @@ # Copyright: (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +# ATTENTION CONTRIBUTORS! +# +# TL;DR: Run this module's integration tests manually before opening a pull request +# +# Long explanation: +# The integration tests for this module are currently NOT run on the Ansible project's continuous +# delivery pipeline. So please: When you make changes to this module, make sure that you run the +# included integration tests manually for both Python 2 and Python 3: +# +# Python 2: +# ansible-test integration -v --docker fedora28 --docker-privileged --allow-unsupported --python 2.7 flatpak_remote +# Python 3: +# ansible-test integration -v --docker fedora28 --docker-privileged --allow-unsupported --python 3.6 flatpak_remote +# +# Because of external dependencies, the current integration tests are somewhat too slow and brittle +# to be included right now. I have plans to rewrite the integration tests based on a local flatpak +# repository so that they can be included into the normal CI pipeline. +# //oolongbrothers + + from __future__ import (absolute_import, division, print_function) __metaclass__ = type @@ -148,7 +169,7 @@ def remote_exists(module, binary, name, method): output = _flatpak_command(module, False, command) for line in output.splitlines(): listed_remote = line.split() - if listed_remote[0] == name: + if listed_remote[0] == to_native(name): return True return False