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

MH mh/mixins/deps.py: prevent deprecation warning when no deps are specified (#6644)

* MH mh/mixins/deps.py: prevent deprecation warning when no deps are specified

* rollback empty "patch" on license markers to prevent test error

* disable test in ansible 2.12

* add changelog frag
This commit is contained in:
Alexei Znamensky 2023-06-09 22:56:10 +12:00 committed by GitHub
parent 07a5f07eaa
commit 494909aba5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- MH DependencyMixin module utils - deprecation notice was popping up for modules not using dependencies (https://github.com/ansible-collections/community.general/pull/6644, https://github.com/ansible-collections/community.general/issues/6639).

View file

@ -52,6 +52,8 @@ class DependencyMixin(ModuleHelperBase):
return cls._dependencies[-1]
def fail_on_missing_deps(self):
if not self._dependencies:
return
self.module.deprecate(
'The DependencyMixin is being deprecated. '
'Modules should use community.general.plugins.module_utils.deps instead.',

View file

@ -36,6 +36,13 @@
path: '{{ bl_file }}'
register: stat_test_1
- name: show bl_test_1
ansible.builtin.debug:
var: bl_test_1_depr_msgs
vars:
bl_test_1_depr_msgs: "{{ (bl_test_1.deprecations | default([])) | map(attribute='msg') }}"
# q('ansible.builtin.subelements', bl_test_1, 'deprecations', {'skip_missing': True}) }}"
- name: assert file is unchanged
assert:
that:
@ -49,12 +56,17 @@
expected_content: |
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-{{ '' }}License-Identifier: GPL-3.0-or-later
# SPDX{{ '' }}-License-Identifier: GPL-3.0-or-later
blacklist aaaa
blacklist bbbb
blacklist cccc
- name: test deprecation
assert:
that:
- "'deprecations' not in bl_test_1 or (ansible_version.major == 2 and ansible_version.minor == 12)"
- name: add new item to list
community.general.kernel_blacklist:
blacklist_file: '{{ bl_file }}'
@ -76,7 +88,7 @@
content: |
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-{{ '' }}License-Identifier: GPL-3.0-or-later
# SPDX{{ '' }}-License-Identifier: GPL-3.0-or-later
blacklist aaaa
blacklist bbbb
@ -104,7 +116,7 @@
content: |
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-{{ '' }}License-Identifier: GPL-3.0-or-later
# SPDX{{ '' }}-License-Identifier: GPL-3.0-or-later
blacklist aaaa
blacklist cccc