mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -07:00
docker_container: show warnings, fix/improve tests (#53440)
* Output warnings from docker daemon on container create and update. * Accept warning for blkio_weight instead of idempotency. * Value quoting. * Avoid loop variable conflict. * Add changelog. * Make one test case faster. * Add 'Docker warning: ' prefix. * Add a generalized warning reporting function.
This commit is contained in:
parent
7bb174214c
commit
3117900b1e
7 changed files with 89 additions and 67 deletions
|
@ -23,6 +23,7 @@ from distutils.version import LooseVersion
|
|||
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||
from ansible.module_utils.common._collections_compat import Mapping, Sequence
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
from ansible.module_utils.parsing.convert_bool import BOOLEANS_TRUE, BOOLEANS_FALSE
|
||||
|
||||
|
@ -660,6 +661,20 @@ class AnsibleDockerClient(Client):
|
|||
|
||||
return new_tag, old_tag == new_tag
|
||||
|
||||
def report_warnings(self, result, warnings_key=None):
|
||||
'''
|
||||
Checks result of client operation for warnings, and if present, outputs them.
|
||||
'''
|
||||
if warnings_key is None:
|
||||
warnings_key = ['Warnings']
|
||||
for key in warnings_key:
|
||||
if not isinstance(result, Mapping):
|
||||
return
|
||||
result = result.get(key)
|
||||
if isinstance(result, Sequence):
|
||||
for warning in result:
|
||||
self.module.warn('Docker warning: {0}'.format(warning))
|
||||
|
||||
|
||||
def compare_dict_allow_more_present(av, bv):
|
||||
'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue