mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #6644/494909ab backport][stable-7] MH mh/mixins/deps.py: prevent deprecation warning when no deps are specified (#6653)
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
(cherry picked from commit 494909aba5
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
04162da6c9
commit
1f518751a1
3 changed files with 19 additions and 3 deletions
2
changelogs/fragments/6644-dependencymixin-fix.yml
Normal file
2
changelogs/fragments/6644-dependencymixin-fix.yml
Normal 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).
|
|
@ -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.',
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue