Compare commits

...
Sign in to create a new pull request.

5 commits

Author SHA1 Message Date
Maxwell G
5c1e441641
Upload missing patch 2022-08-19 15:27:29 -05:00
Maxwell G
1e2d60d2de
Adopt new licensing guidelines 2022-08-19 15:15:58 -05:00
Maxwell G
0bf04a1127
Fix shebang handling 2022-08-19 15:15:52 -05:00
Maxwell G
79c9b8a25f
Use new macros for unit testing 2022-08-19 15:15:30 -05:00
Maxwell G
47d5722ba0
Update to 2.7.1. 2022-08-19 14:46:01 -05:00
5 changed files with 144 additions and 32 deletions

1
.gitignore vendored
View file

@ -8,3 +8,4 @@
/community.docker-2.5.0.tar.gz
/community.docker-2.5.1.tar.gz
/community.docker-2.6.0.tar.gz
/community.docker-2.7.1.tar.gz

View file

@ -3,38 +3,36 @@
%global forgeurl https://github.com/ansible-collections/%{collection_namespace}.%{collection_name}
# Only run tests where %%generate_buildrequires and test deps are available.
%if 0%{?fedora}
%bcond_without tests
%if %{defined fedora}
%bcond_without tests
%else
%bcond_with tests
%bcond_with tests
%endif
Name: ansible-collection-%{collection_namespace}-%{collection_name}
Version: 2.6.0
Version: 2.7.1
%global tag %{version}
%forgemeta
Release: 1%{?dist}
Summary: Ansible modules and plugins for working with Docker
# All files are GPLv3+ except plugins/module_utils/_version.py.
License: GPLv3+ and Python
# All files are GPL-3.0-or-later except plugins/module_utils/_version.py.
License: GPL-3.0-or-later and Python
URL: %{ansible_collection_url}
Source0: %{forgesource}
Source1: %{name}.rpmlintrc
# Downstream only patch to remove tests, CI configuration, and other
# unnecessary development files from the built collection.
Patch0: build_ignore-unnecessary-files.patch
Patch1: https://github.com/ansible-collections/community.docker/pull/433.patch#/remove-python-mock.patch
BuildArch: noarch
# Needed for %%py3_shebang_fix.
Buildrequires: python3-devel
BuildRequires: ansible-packaging
# The new ansible-core, specifically, is required for the `build_ignore:` patch and ansible-test to work properly.
# Therefore, we cannot rely on ansible-packaging which might pull in ansible 2.9.
BuildRequires: ansible-core
%if %{with tests}
BuildRequires: /usr/bin/ansible-test
BuildRequires: ansible-packaging-tests
BuildRequires: %{py3_dist docker}
%endif
@ -46,14 +44,7 @@ working with Docker.
%prep
%forgeautosetup -p1
%global py3_shbang_opts %{nil}
%py3_shebang_fix .
%if %{with tests}
%generate_buildrequires
%pyproject_buildrequires -N tests/unit/requirements.txt %{python3_sitelib}/ansible_test/_data/requirements/units.txt
%endif
find -type f ! -executable -name '*.py' -print -exec sed -i -e '1{\@^#!.*@d}' '{}' +
%build
@ -66,14 +57,7 @@ working with Docker.
%check
%if %{with tests}
mkdir -p ../ansible_collections/%{collection_namespace}
cp -a $(pwd) ../ansible_collections/%{collection_namespace}/%{collection_name}
pushd ../ansible_collections/%{collection_namespace}/%{collection_name}
# mkdir -p ansible_collections/%%{collection_namespace}
# ln -sr . ansible_collections/%%{collection_namespace}/%%{collection_name}
# pushd ansible_collections/%%{collection_namespace}/%%{collection_name}
ansible-test units --python-interpreter %{__python3} --local
popd
%ansible_test_unit
%endif
@ -84,6 +68,9 @@ popd
%changelog
* Fri Aug 19 2022 Maxwell G <gotmax@e.email> - 2.7.1-1
- Update to 2.7.1.
* Wed May 25 2022 Maxwell G <gotmax@e.email> - 2.6.0-1
- Update to 2.6.0. Fixes rhbz#2089991.

View file

@ -1,7 +1,7 @@
diff -Naur a/galaxy.yml b/galaxy.yml
--- a/galaxy.yml 2022-04-25 14:32:27.000000000 -0500
+++ b/galaxy.yml 2022-04-29 21:07:55.917219135 -0500
@@ -18,3 +18,9 @@
@@ -18,3 +18,8 @@
# https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#ignoring-files-and-folders
- .gitignore
- changelogs/.plugin-cache.yaml
@ -10,4 +10,3 @@ diff -Naur a/galaxy.yml b/galaxy.yml
+ - .azure-pipelines
+ - changelogs/fragments/.keep
+ - docs
+ - .pyproject-builddir

125
remove-python-mock.patch Normal file
View file

@ -0,0 +1,125 @@
From 7e9eee69c273515129cc0ac0e425b4b2c7da9263 Mon Sep 17 00:00:00 2001
From: Maxwell G <gotmax@e.email>
Date: Thu, 28 Jul 2022 13:57:18 +0200
Subject: [PATCH 1/2] Prefer unitest.mock by using compat.mock
`mock` is a backport of the `unittest.mock` module from the stdlib, and
there's no reason to use it on newer Python versions. `mock` is deprecated
in Fedora, so I figured I'd propose this here before downstream patching
our ansible-collection-community-docker package.
---
tests/unit/plugins/inventory/test_docker_containers.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/unit/plugins/inventory/test_docker_containers.py b/tests/unit/plugins/inventory/test_docker_containers.py
index 1c831b21..74721bfe 100644
--- a/tests/unit/plugins/inventory/test_docker_containers.py
+++ b/tests/unit/plugins/inventory/test_docker_containers.py
@@ -11,7 +11,7 @@
import pytest
-from mock import MagicMock
+from ansible_collections.community.docker.tests.unit.compat.mock import MagicMock
from ansible import constants as C
from ansible.errors import AnsibleError
From 0efaff6a01c113980a70b92e93bdadd7237a7949 Mon Sep 17 00:00:00 2001
From: Maxwell G <gotmax@e.email>
Date: Thu, 28 Jul 2022 14:15:53 +0200
Subject: [PATCH 2/2] Remove compat.mock code for older Python 3 versions
This removes compatibility for older versions of Python 3 that are no
longer supported.
---
tests/unit/compat/mock.py | 79 ---------------------------------------
1 file changed, 79 deletions(-)
diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py
index f8f565dc..515b94a3 100644
--- a/tests/unit/compat/mock.py
+++ b/tests/unit/compat/mock.py
@@ -28,82 +28,3 @@
from mock import *
except ImportError:
print('You need the mock library installed on python2.x to run tests')
-
-
-# Prior to 3.4.4, mock_open cannot handle binary read_data
-if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
- file_spec = None
-
- def _iterate_read_data(read_data):
- # Helper for mock_open:
- # Retrieve lines from read_data via a generator so that separate calls to
- # readline, read, and readlines are properly interleaved
- sep = b'\n' if isinstance(read_data, bytes) else '\n'
- data_as_list = [l + sep for l in read_data.split(sep)]
-
- if data_as_list[-1] == sep:
- # If the last line ended in a newline, the list comprehension will have an
- # extra entry that's just a newline. Remove this.
- data_as_list = data_as_list[:-1]
- else:
- # If there wasn't an extra newline by itself, then the file being
- # emulated doesn't have a newline to end the last line remove the
- # newline that our naive format() added
- data_as_list[-1] = data_as_list[-1][:-1]
-
- for line in data_as_list:
- yield line
-
- def mock_open(mock=None, read_data=''):
- """
- A helper function to create a mock to replace the use of `open`. It works
- for `open` called directly or used as a context manager.
-
- The `mock` argument is the mock object to configure. If `None` (the
- default) then a `MagicMock` will be created for you, with the API limited
- to methods or attributes available on standard file handles.
-
- `read_data` is a string for the `read` methoddline`, and `readlines` of the
- file handle to return. This is an empty string by default.
- """
- def _readlines_side_effect(*args, **kwargs):
- if handle.readlines.return_value is not None:
- return handle.readlines.return_value
- return list(_data)
-
- def _read_side_effect(*args, **kwargs):
- if handle.read.return_value is not None:
- return handle.read.return_value
- return type(read_data)().join(_data)
-
- def _readline_side_effect():
- if handle.readline.return_value is not None:
- while True:
- yield handle.readline.return_value
- for line in _data:
- yield line
-
- global file_spec
- if file_spec is None:
- import _io
- file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
-
- if mock is None:
- mock = MagicMock(name='open', spec=open)
-
- handle = MagicMock(spec=file_spec)
- handle.__enter__.return_value = handle
-
- _data = _iterate_read_data(read_data)
-
- handle.write.return_value = None
- handle.read.return_value = None
- handle.readline.return_value = None
- handle.readlines.return_value = None
-
- handle.read.side_effect = _read_side_effect
- handle.readline.side_effect = _readline_side_effect()
- handle.readlines.side_effect = _readlines_side_effect
-
- mock.return_value = handle
- return mock

View file

@ -1 +1 @@
SHA512 (community.docker-2.6.0.tar.gz) = 8cd8bb735576324c57bc0a897e3ae080d08762b74f9f33072a5b95b8e07adc0ee50c5f4226cb620ebd6ad7a121b3a88b26f61b65bd4f2ad254b165acf1b9c2e1
SHA512 (community.docker-2.7.1.tar.gz) = 4b0b3bd123729d35fbb70c7ddc90eb67154e17e53762be9a9ccc4cf63081b4a4f4e73a050a881d56bd13cd119e14785259777e2caf64a89243403eec8e99d8ea