1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Bump version to 2.0.0 (#1369)

* Bump version to 2.0.0.

* Remove deprecated 2.0.0 features.

* Test for failure.

* Fix cache plugin unit tests.

* Accept direct import only for Ansible 2.9.
This commit is contained in:
Felix Fontein 2020-11-26 14:26:36 +01:00 committed by GitHub
parent 25c52d56bd
commit 1db167b12a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 50 deletions

View file

@ -0,0 +1,5 @@
removed_features:
- "iptables_state - the ``ANSIBLE_ASYNC_DIR`` environment is no longer supported, use the ``async_dir`` shell option instead (https://github.com/ansible-collections/community.general/pull/1371)."
- "memcached cache plugin - do not import ``CacheModule``s directly. Use ``ansible.plugins.loader.cache_loader`` instead (https://github.com/ansible-collections/community.general/pull/1371)."
- "redis cache plugin - do not import ``CacheModule``s directly. Use ``ansible.plugins.loader.cache_loader`` instead (https://github.com/ansible-collections/community.general/pull/1371)."
- "xml - when ``content=attribute``, the ``attribute`` option is ignored (https://github.com/ansible-collections/community.general/pull/1371)."

View file

@ -1,6 +1,6 @@
namespace: community
name: general
version: 1.3.0
version: 2.0.0
readme: README.md
authors:
- Ansible (https://github.com/ansible)

View file

@ -98,25 +98,9 @@ class ActionModule(ActionBase):
task_async,
max_timeout))
# BEGIN snippet from async_status action plugin
env_async_dir = [e for e in self._task.environment if
"ANSIBLE_ASYNC_DIR" in e]
if len(env_async_dir) > 0:
# for backwards compatibility we need to get the dir from
# ANSIBLE_ASYNC_DIR that is defined in the environment. This is
# deprecated and will be removed in favour of shell options
async_dir = env_async_dir[0]['ANSIBLE_ASYNC_DIR']
msg = "Setting the async dir from the environment keyword " \
"ANSIBLE_ASYNC_DIR is deprecated. Set the async_dir " \
"shell option instead"
display.deprecated(msg, version='2.0.0',
collection_name='community.general') # was Ansible 2.12
else:
# inject the async directory based on the shell option into the
# module args
async_dir = self.get_shell_option('async_dir', default="~/.ansible_async")
# END snippet from async_status action plugin
# Bind the loop max duration to consistent values on both
# remote and local sides (if not the same, make the loop

View file

@ -53,6 +53,7 @@ from ansible import constants as C
from ansible.errors import AnsibleError
from ansible.module_utils.common._collections_compat import MutableSet
from ansible.plugins.cache import BaseCacheModule
from ansible.release import __version__ as ansible_base_version
from ansible.utils.display import Display
try:
@ -180,9 +181,9 @@ class CacheModule(BaseCacheModule):
self._timeout = self.get_option('_timeout')
self._prefix = self.get_option('_prefix')
except KeyError:
display.deprecated('Rather than importing CacheModules directly, '
'use ansible.plugins.loader.cache_loader',
version='2.0.0', collection_name='community.general') # was Ansible 2.12
# TODO: remove once we no longer support Ansible 2.9
if not ansible_base_version.startswith('2.9.'):
raise AnsibleError("Do not import CacheModules directly. Use ansible.plugins.loader.cache_loader instead.")
if C.CACHE_PLUGIN_CONNECTION:
connection = C.CACHE_PLUGIN_CONNECTION.split(',')
self._timeout = C.CACHE_PLUGIN_TIMEOUT

View file

@ -69,6 +69,7 @@ from ansible.errors import AnsibleError
from ansible.module_utils._text import to_native
from ansible.parsing.ajson import AnsibleJSONEncoder, AnsibleJSONDecoder
from ansible.plugins.cache import BaseCacheModule
from ansible.release import __version__ as ansible_base_version
from ansible.utils.display import Display
try:
@ -103,9 +104,9 @@ class CacheModule(BaseCacheModule):
self._keys_set = self.get_option('_keyset_name')
self._sentinel_service_name = self.get_option('_sentinel_service_name')
except KeyError:
display.deprecated('Rather than importing CacheModules directly, '
'use ansible.plugins.loader.cache_loader',
version='2.0.0', collection_name='community.general') # was Ansible 2.12
# TODO: remove once we no longer support Ansible 2.9
if not ansible_base_version.startswith('2.9.'):
raise AnsibleError("Do not import CacheModules directly. Use ansible.plugins.loader.cache_loader instead.")
if C.CACHE_PLUGIN_CONNECTION:
uri = C.CACHE_PLUGIN_CONNECTION
self._timeout = float(C.CACHE_PLUGIN_TIMEOUT)

View file

@ -826,8 +826,7 @@ def main():
supports_check_mode=True,
required_by=dict(
add_children=['xpath'],
# TODO: Reinstate this in community.general 2.0.0 when we have deprecated the incorrect use below
# attribute=['value'],
attribute=['value'],
content=['xpath'],
set_children=['xpath'],
value=['xpath'],
@ -876,12 +875,6 @@ def main():
elif LooseVersion('.'.join(to_native(f) for f in etree.LXML_VERSION)) < LooseVersion('3.0.0'):
module.warn('Using lxml version lower than 3.0.0 does not guarantee predictable element attribute order.')
# Report wrongly used attribute parameter when using content=attribute
# TODO: Remove this in community.general 2.0.0 (and reinstate strict parameter test above) and remove the integration test example
if content == 'attribute' and attribute is not None:
module.deprecate("Parameter 'attribute=%s' is ignored when using 'content=attribute' only 'xpath' is used. Please remove entry." % attribute,
version='2.0.0', collection_name='community.general') # was Ansible 2.12
# Check if the file exists
if xml_string:
infile = BytesIO(to_bytes(xml_string, errors='surrogate_or_strict'))

View file

@ -19,24 +19,19 @@
- get_element_attribute.matches[0]['rating'] is defined
- get_element_attribute.matches[0]['rating']['subjective'] == 'true'
# TODO: Remove this in 2.0.0 when this incorrect use of attribute is deprecated
- name: Get element attributes
- name: Get element attributes (should fail)
xml:
path: /tmp/ansible-xml-beers.xml
xpath: /business/rating
content: attribute
attribute: subjective
register: get_element_attribute_wrong
ignore_errors: true
- name: Test expected result
assert:
that:
- get_element_attribute_wrong.changed == false
- get_element_attribute_wrong.matches[0]['rating'] is defined
- get_element_attribute_wrong.matches[0]['rating']['subjective'] == 'true'
- get_element_attribute_wrong.deprecations is defined
- get_element_attribute_wrong.deprecations[0].msg == "Parameter 'attribute=subjective' is ignored when using 'content=attribute' only 'xpath' is used. Please remove entry."
- get_element_attribute_wrong.deprecations[0].version == '2.0.0'
- get_element_attribute_wrong is failed
- name: Get element text
xml:

View file

@ -28,8 +28,4 @@ from ansible_collections.community.general.plugins.cache.memcached import CacheM
def test_memcached_cachemodule():
assert isinstance(MemcachedCache(), MemcachedCache)
def test_memcached_cachemodule_with_loader():
assert isinstance(cache_loader.get('community.general.memcached'), MemcachedCache)

View file

@ -28,9 +28,5 @@ from ansible_collections.community.general.plugins.cache.redis import CacheModul
def test_redis_cachemodule():
assert isinstance(RedisCache(), RedisCache)
def test_redis_cachemodule_with_loader():
# The _uri option is required for the redis plugin
assert isinstance(cache_loader.get('community.general.redis', **{'_uri': '127.0.0.1:6379:1'}), RedisCache)