ansible-galaxy fix scm dependency error (#81599)

* 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>
pull/81763/head
Brian Coca 2 years ago committed by GitHub
parent 7c7385521e
commit 2aef0406d4
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.

@ -544,7 +544,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
@ -741,7 +741,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
@ -1868,8 +1868,7 @@ def _resolve_depenency_map(
raise AnsibleError('\n'.join(error_msg_lines)) from dep_exc
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
]

@ -463,8 +463,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 (
@ -504,14 +504,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