Created
June 10, 2020 17:59
-
-
Save s-hertel/1dc8415e3f5b24cd62c456eba1c0f83b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py | |
index 79aa3eb1ec..079e488128 100644 | |
--- a/lib/ansible/cli/doc.py | |
+++ b/lib/ansible/cli/doc.py | |
@@ -161,6 +161,7 @@ class DocCLI(CLI): | |
# add to plugin paths from command line | |
basedir = context.CLIARGS['basedir'] | |
if basedir: | |
+ basedir = os.path.abspath(basedir) | |
AnsibleCollectionConfig.playbook_paths = basedir | |
loader.add_directory(basedir, with_subdir=True) | |
diff --git a/lib/ansible/utils/collection_loader/_collection_finder.py b/lib/ansible/utils/collection_loader/_collection_finder.py | |
index 6aa3ca5ab4..c7d1d5fd5a 100644 | |
--- a/lib/ansible/utils/collection_loader/_collection_finder.py | |
+++ b/lib/ansible/utils/collection_loader/_collection_finder.py | |
@@ -385,15 +385,20 @@ class _AnsibleCollectionPkgLoaderBase: | |
if not path[0] == '/': | |
# relative to current package, search package paths if possible (this may not be necessary) | |
# candidate_paths = [os.path.join(ssp, path) for ssp in self._subpackage_search_paths] | |
- raise ValueError('relative resource paths not supported') | |
+ raise ValueError('relative resource paths not supported: %s' % to_native(path)) | |
else: | |
candidate_paths = [path] | |
for p in candidate_paths: | |
b_path = to_bytes(p) | |
if os.path.isfile(b_path): | |
- with open(b_path, 'rb') as fd: | |
- return fd.read() | |
+ try: | |
+ with open(b_path, 'rb') as fd: | |
+ return fd.read() | |
+ except (IOError, OSError) as e: | |
+ # cannot read file for some reason | |
+ # TODO: report error/warning once we decide to allow errors/warnings from this class | |
+ pass | |
return None | |
diff --git a/test/integration/targets/ansible-doc/runme.sh b/test/integration/targets/ansible-doc/runme.sh | |
index 7cc6bfe449..59eed2b519 100755 | |
--- a/test/integration/targets/ansible-doc/runme.sh | |
+++ b/test/integration/targets/ansible-doc/runme.sh | |
@@ -7,6 +7,9 @@ ansible-playbook test.yml -i inventory "$@" | |
unset ANSIBLE_PLAYBOOK_DIR | |
cd "$(dirname "$0")" | |
+abs_path="> FAKEMODULE ($(pwd)/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py)" | |
+sed -i "s|> FAKEMODULE.*|${abs_path}|g" fakemodule.output | |
+ | |
# test module docs from collection | |
current_out="$(ansible-doc --playbook-dir ./ testns.testcol.fakemodule)" | |
expected_out="$(cat fakemodule.output)" | |
@@ -16,9 +19,9 @@ test "$current_out" == "$expected_out" | |
for ptype in cache inventory lookup vars | |
do | |
# each plugin type adds 1 from collection | |
- # FIXME pre=$(ansible-doc -l -t ${ptype}|wc -l) | |
- # FIXME post=$(ansible-doc -l -t ${ptype} --playbook-dir ./|wc -l) | |
- # FIXME test "$pre" -eq $((post - 1)) | |
+ pre=$(ansible-doc -l -t ${ptype}|wc -l) | |
+ post=$(ansible-doc -l -t ${ptype} --playbook-dir ./|wc -l) | |
+ test "$pre" -eq $((post - 1)) | |
# ensure we ONLY list from the collection | |
justcol=$(ansible-doc -l -t ${ptype} --playbook-dir ./ testns.testcol|wc -l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment