diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2023-09-21 21:49:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-21 21:49:30 +0200 |
commit | 2aef0406d403f8daf4a9eed40cce3e08bb8ee122 (patch) | |
tree | 596b552a2fbc2743c817ba0fb3f3fdd0d6748a5a | |
parent | Harden the ansiballz and respawn python templates (#81753) (diff) | |
download | ansible-2aef0406d403f8daf4a9eed40cce3e08bb8ee122.tar.xz ansible-2aef0406d403f8daf4a9eed40cce3e08bb8ee122.zip |
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>
-rw-r--r-- | changelogs/fragments/galaxy_dep_res_msgs.yml | 4 | ||||
-rw-r--r-- | lib/ansible/galaxy/collection/__init__.py | 7 | ||||
-rw-r--r-- | lib/ansible/galaxy/dependency_resolution/dataclasses.py | 8 |
3 files changed, 11 insertions, 8 deletions
diff --git a/changelogs/fragments/galaxy_dep_res_msgs.yml b/changelogs/fragments/galaxy_dep_res_msgs.yml new file mode 100644 index 0000000000..733262b107 --- /dev/null +++ b/changelogs/fragments/galaxy_dep_res_msgs.yml @@ -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. diff --git a/lib/ansible/galaxy/collection/__init__.py b/lib/ansible/galaxy/collection/__init__.py index 9bb9e941a4..970c6d3095 100644 --- a/lib/ansible/galaxy/collection/__init__.py +++ b/lib/ansible/galaxy/collection/__init__.py @@ -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 ] diff --git a/lib/ansible/galaxy/dependency_resolution/dataclasses.py b/lib/ansible/galaxy/dependency_resolution/dataclasses.py index 7e8fb57a32..171f71a027 100644 --- a/lib/ansible/galaxy/dependency_resolution/dataclasses.py +++ b/lib/ansible/galaxy/dependency_resolution/dataclasses.py @@ -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] |