summaryrefslogtreecommitdiff
path: root/lib/ansible/galaxy/dependency_resolution/dataclasses.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/galaxy/dependency_resolution/dataclasses.py')
-rw-r--r--lib/ansible/galaxy/dependency_resolution/dataclasses.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/ansible/galaxy/dependency_resolution/dataclasses.py b/lib/ansible/galaxy/dependency_resolution/dataclasses.py
index 2ac6892531..0a942d4cce 100644
--- a/lib/ansible/galaxy/dependency_resolution/dataclasses.py
+++ b/lib/ansible/galaxy/dependency_resolution/dataclasses.py
@@ -27,7 +27,7 @@ if t.TYPE_CHECKING:
)
-from ansible.errors import AnsibleError
+from ansible.errors import AnsibleError, AnsibleAssertionError
from ansible.galaxy.api import GalaxyAPI
from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.module_utils.common.arg_spec import ArgumentSpecValidator
@@ -571,3 +571,13 @@ class Candidate(
def __init__(self, *args, **kwargs):
super(Candidate, self).__init__()
+
+ def with_signatures_repopulated(self): # type: (Candidate) -> Candidate
+ """Populate a new Candidate instance with Galaxy signatures.
+ :raises AnsibleAssertionError: If the supplied candidate is not sourced from a Galaxy-like index.
+ """
+ if self.type != 'galaxy':
+ raise AnsibleAssertionError(f"Invalid collection type for {self!r}: unable to get signatures from a galaxy server.")
+
+ signatures = self.src.get_collection_signatures(self.namespace, self.name, self.ver)
+ return self.__class__(self.fqcn, self.ver, self.src, self.type, frozenset([*self.signatures, *signatures]))