mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 03:52:05 +00:00
Fix docker_plugin crash when handling plugin options (#447)
* Fix docker_plugin crash when handling plugin options. * Try to add tests.
This commit is contained in:
parent
f513ba2c59
commit
a50257381f
2
changelogs/fragments/447-docker_plugin-bug.yml
Normal file
2
changelogs/fragments/447-docker_plugin-bug.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- "docker_plugin - fix crash when handling plugin options (https://github.com/ansible-collections/community.docker/issues/446, https://github.com/ansible-collections/community.docker/pull/447)."
|
||||||
@ -245,7 +245,7 @@ class DockerPluginManager(object):
|
|||||||
self.existing_plugin = self.client.get_json('/plugins/{0}/json', self.preferred_name)
|
self.existing_plugin = self.client.get_json('/plugins/{0}/json', self.preferred_name)
|
||||||
if self.parameters.plugin_options:
|
if self.parameters.plugin_options:
|
||||||
data = prepare_options(self.parameters.plugin_options)
|
data = prepare_options(self.parameters.plugin_options)
|
||||||
self.client.post_json('/plugins/{0}/set', self.preferred_name, data=['{0}={1}'.format(k, v) for k, v in data.items()])
|
self.client.post_json('/plugins/{0}/set', self.preferred_name, data=data)
|
||||||
except APIError as e:
|
except APIError as e:
|
||||||
self.client.fail(to_native(e))
|
self.client.fail(to_native(e))
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ class DockerPluginManager(object):
|
|||||||
if not self.check_mode:
|
if not self.check_mode:
|
||||||
try:
|
try:
|
||||||
data = prepare_options(self.parameters.plugin_options)
|
data = prepare_options(self.parameters.plugin_options)
|
||||||
self.client.post_json('/plugins/{0}/set', self.preferred_name, data=['{0}={1}'.format(k, v) for k, v in data.items()])
|
self.client.post_json('/plugins/{0}/set', self.preferred_name, data=data)
|
||||||
except APIError as e:
|
except APIError as e:
|
||||||
self.client.fail(to_native(e))
|
self.client.fail(to_native(e))
|
||||||
self.actions.append("Updated plugin %s settings" % self.preferred_name)
|
self.actions.append("Updated plugin %s settings" % self.preferred_name)
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
- name: Create random name prefix
|
- name: Create random name prefix
|
||||||
set_fact:
|
set_fact:
|
||||||
name_prefix: "cvmfs/overlay2-graphdriver"
|
name_prefix: "vieux/sshfs"
|
||||||
plugin_names: []
|
plugin_names: []
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
@ -62,6 +62,12 @@
|
|||||||
state: absent
|
state: absent
|
||||||
register: absent_4
|
register: absent_4
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
docker_plugin:
|
||||||
|
plugin_name: "{{ plugin_name }}"
|
||||||
|
state: absent
|
||||||
|
force_remove: true
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- create_1 is changed
|
- create_1 is changed
|
||||||
@ -75,10 +81,48 @@
|
|||||||
|
|
||||||
############ Plugin_Options ############
|
############ Plugin_Options ############
|
||||||
########################################
|
########################################
|
||||||
# Integration-Test with plugin_options is in TODO-List
|
|
||||||
|
- name: Install a plugin with options
|
||||||
|
docker_plugin:
|
||||||
|
plugin_name: "{{ plugin_name }}"
|
||||||
|
plugin_options:
|
||||||
|
DEBUG: '1'
|
||||||
|
state: present
|
||||||
|
register: create_1
|
||||||
|
|
||||||
|
- name: Install a plugin with options (idempotent)
|
||||||
|
docker_plugin:
|
||||||
|
plugin_name: "{{ plugin_name }}"
|
||||||
|
plugin_options:
|
||||||
|
DEBUG: '1'
|
||||||
|
state: present
|
||||||
|
register: create_2
|
||||||
|
|
||||||
|
- name: Install a plugin with different options
|
||||||
|
docker_plugin:
|
||||||
|
plugin_name: "{{ plugin_name }}"
|
||||||
|
plugin_options:
|
||||||
|
DEBUG: '0'
|
||||||
|
state: present
|
||||||
|
register: update_1
|
||||||
|
|
||||||
|
- name: Install a plugin with different options (idempotent)
|
||||||
|
docker_plugin:
|
||||||
|
plugin_name: "{{ plugin_name }}"
|
||||||
|
plugin_options:
|
||||||
|
DEBUG: '0'
|
||||||
|
state: present
|
||||||
|
register: update_2
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
docker_plugin:
|
docker_plugin:
|
||||||
plugin_name: "{{ plugin_name }}"
|
plugin_name: "{{ plugin_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
force_remove: true
|
force_remove: true
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- create_1 is changed
|
||||||
|
- create_2 is not changed
|
||||||
|
- update_1 is changed
|
||||||
|
- update_2 is not changed
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user