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

Fix bug in plugin path caching

Fixes #9263
This commit is contained in:
James Cammarata 2014-10-04 21:40:59 -05:00
parent 8cecb0690f
commit 05644686de
4 changed files with 20 additions and 9 deletions

View file

@ -94,10 +94,8 @@ class PluginLoader(object):
m = __import__(self.package)
parts = self.package.split('.')[1:]
self.package_path = os.path.join(os.path.dirname(m.__file__), *parts)
paths.extend(self._all_directories(self.package_path))
return paths
else:
return [ self.package_path ]
paths.extend(self._all_directories(self.package_path))
return paths
def _get_paths(self):
''' Return a list of paths to search for plugins in '''
@ -105,8 +103,7 @@ class PluginLoader(object):
if self._paths is not None:
return self._paths
ret = []
ret += self._extra_dirs
ret = self._extra_dirs[:]
for basedir in _basedirs:
fullpath = os.path.realpath(os.path.join(basedir, self.subdir))
if os.path.isdir(fullpath):
@ -139,11 +136,9 @@ class PluginLoader(object):
# look for any plugins installed in the package subtree
ret.extend(self._get_package_paths())
package_dirs = self._get_package_paths()
# cache and return the result
self._paths = ret
return ret
@ -156,7 +151,9 @@ class PluginLoader(object):
if with_subdir:
directory = os.path.join(directory, self.subdir)
if directory not in self._extra_dirs:
# append the directory and invalidate the path cache
self._extra_dirs.append(directory)
self._paths = None
def find_plugin(self, name, suffixes=None, transport=''):
''' Find a plugin named name '''

View file

@ -38,3 +38,5 @@
- { role: test_script, tags: test_script }
- { role: test_authorized_key, tags: test_authorized_key }
- { role: test_get_url, tags: test_get_url }
- { role: test_embedded_module, tags: test_embedded_module }

View file

@ -0,0 +1,3 @@
#!/usr/bin/env python
print '{"changed":false, "msg":"this is the embedded module"}'

View file

@ -0,0 +1,9 @@
- name: run the embedded dummy module
test_integration_module:
register: result
- name: assert the embedded module ran
assert:
that:
- "'msg' in result"
- result.msg == "this is the embedded module"