ansible-galaxy fix scm dependency error (#81599) (#81799)

* ansible-galaxy fix scm dependency error

  also changed usage of 'virtual colleciton' to actual type
  avoid error by filtering out virtual collections that dont have
expected properties

simplified as per webknjaz

* Update lib/ansible/galaxy/collection/__init__.py
Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>

(cherry picked from commit 2aef0406d4)
pull/81836/head
Brian Coca 1 year ago committed by GitHub
parent e9f685f39f
commit 7f0b39271c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,4 @@
minor_changes:
- ansible-galaxy dependency resolution messages have changed the unexplained 'virtual' collection for the specific type ('scm', 'dir', etc) that is more user friendly
bugfixes:
- ansible-galaxy error on dependency resolution will not error itself due to 'virtual' collections not having a name/namespace.

@ -545,7 +545,7 @@ def download_collections(
for fqcn, concrete_coll_pin in dep_map.copy().items(): # FIXME: move into the provider
if concrete_coll_pin.is_virtual:
display.display(
'Virtual collection {coll!s} is not downloadable'.
'{coll!s} is not downloadable'.
format(coll=to_text(concrete_coll_pin)),
)
continue
@ -744,7 +744,7 @@ def install_collections(
for fqcn, concrete_coll_pin in dependency_map.items():
if concrete_coll_pin.is_virtual:
display.vvvv(
"'{coll!s}' is virtual, skipping.".
"Encountered {coll!s}, skipping.".
format(coll=to_text(concrete_coll_pin)),
)
continue
@ -1804,8 +1804,7 @@ def _resolve_depenency_map(
)
except CollectionDependencyInconsistentCandidate as dep_exc:
parents = [
"%s.%s:%s" % (p.namespace, p.name, p.ver)
for p in dep_exc.criterion.iter_parent()
str(p) for p in dep_exc.criterion.iter_parent()
if p is not None
]

@ -440,8 +440,8 @@ class _ComputedReqKindsMixin:
def __unicode__(self):
if self.fqcn is None:
return (
u'"virtual collection Git repo"' if self.is_scm
else u'"virtual collection namespace"'
f'{self.type} collection from a Git repo' if self.is_scm
else f'{self.type} collection from a namespace'
)
return (
@ -481,14 +481,14 @@ class _ComputedReqKindsMixin:
@property
def namespace(self):
if self.is_virtual:
raise TypeError('Virtual collections do not have a namespace')
raise TypeError(f'{self.type} collections do not have a namespace')
return self._get_separate_ns_n_name()[0]
@property
def name(self):
if self.is_virtual:
raise TypeError('Virtual collections do not have a name')
raise TypeError(f'{self.type} collections do not have a name')
return self._get_separate_ns_n_name()[-1]

Loading…
Cancel
Save