mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 03:46:55 +00:00
docker_plugin: do not crash when plugin doesn't exist (#553)
* Do not crash when plugin doesn't exist. * Improve style. Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com> Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
This commit is contained in:
@@ -346,11 +346,18 @@ class DockerPluginManager(object):
|
||||
|
||||
@property
|
||||
def result(self):
|
||||
plugin_data = {}
|
||||
if self.parameters.state != 'absent':
|
||||
try:
|
||||
plugin_data = self.client.get_json('/plugins/{0}/json', self.preferred_name)
|
||||
except NotFound:
|
||||
# This can happen in check mode
|
||||
pass
|
||||
result = {
|
||||
'actions': self.actions,
|
||||
'changed': self.changed,
|
||||
'diff': self.diff,
|
||||
'plugin': self.client.get_json('/plugins/{0}/json', self.preferred_name) if self.parameters.state != 'absent' else {}
|
||||
'plugin': plugin_data,
|
||||
}
|
||||
return dict((k, v) for k, v in result.items() if v is not None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user