ansible-galaxy, dont display internals (#85571)

Also note broken test for invalid collection paths

Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
pull/85599/head
Brian Coca 4 months ago committed by GitHub
parent 340ca1b493
commit 5faa256178
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- ansible-galaxy no longer shows the internal protomatter collection when listing.

@ -84,6 +84,7 @@ if t.TYPE_CHECKING:
FileManifestEntryType = t.Dict[FileMetaKeysType, t.Union[str, int, None]]
FilesManifestType = t.Dict[t.Literal['files', 'format'], t.Union[t.List[FileManifestEntryType], int]]
import ansible
import ansible.constants as C
from ansible.errors import AnsibleError
from ansible.galaxy.api import GalaxyAPI
@ -143,6 +144,8 @@ ModifiedContent = namedtuple('ModifiedContent', ['filename', 'expected', 'instal
SIGNATURE_COUNT_RE = r"^(?P<strict>\+)?(?:(?P<count>\d+)|(?P<all>all))$"
_ANSIBLE_PACKAGE_PATH = pathlib.Path(ansible.__file__).parent
@dataclass
class ManifestControl:
@ -1429,9 +1432,12 @@ def find_existing_collections(path_filter, artifacts_manager, namespace_filter=N
paths = set()
for path in files('ansible_collections').glob('*/*/'):
path = _normalize_collection_path(path)
if not path.is_dir():
if path.is_relative_to(_ANSIBLE_PACKAGE_PATH):
# skip internal path, those collections are not for galaxy use
continue
elif not path.is_dir():
continue
if path_filter:
elif path_filter:
for pf in path_filter:
try:
path.relative_to(_normalize_collection_path(pf))

@ -155,9 +155,12 @@
environment:
ANSIBLE_COLLECTIONS_PATH: "i_dont_exist"
- assert:
- name: Ensure we get the expected error
assert:
that:
- "'{}' not in list_result_error.stdout"
# FIXME: This test is currently incorrect, but not a fix to do in this PR, proper test is the commented out one.
- "'{}' in list_result_error.stdout"
#- "'None of the provided paths were usable' in list_result_error.stderr"
- name: install an artifact to the second collections path
command: ansible-galaxy collection install namespace1.name1 -s galaxy_ng {{ galaxy_verbosity }} -p "{{ galaxy_dir }}/prod"

Loading…
Cancel
Save