Skip to content

Commit

Permalink
Add AnsibleCollection support
Browse files Browse the repository at this point in the history
  • Loading branch information
vsedmik authored Mar 5, 2024
1 parent 82860cb commit edb6958
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Colored(Box):
'yum': "yum",
'ostree': "ostree",
'docker': "docker",
'ansible_collection': "ansible collection",
'ansible_collection': "ansible_collection",
'file': "file",
}

Expand Down
28 changes: 28 additions & 0 deletions robottelo/host_helpers/repository_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,34 @@ def create(self, organization_id, product_id, download_policy=None, synchronize=
return repo_info


class AnsibleRepository(BaseRepository):
"""Custom Ansible Collection repository"""

_type = constants.REPO_TYPE['ansible_collection']

def __init__(self, url=None, distro=None, requirements=None):
self._requirements = requirements
super().__init__(url=url, distro=distro)

@property
def requirements(self):
return self._requirements

def create(self, organization_id, product_id, download_policy=None, synchronize=True):
repo_info = self.satellite.cli_factory.make_repository(
{
'product-id': product_id,
'content-type': self.content_type,
'url': self.url,
'ansible-collection-requirements': f'{{collections: {self.requirements}}}',
}
)
self._repo_info = repo_info
if synchronize:
self.synchronize()
return repo_info


class OSTreeRepository(BaseRepository):
"""Custom OSTree repository"""

Expand Down
2 changes: 1 addition & 1 deletion tests/foreman/ui/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def test_positive_sync_ansible_collection_gallaxy_repo(session, module_prod):
module_prod.name,
{
'name': repo_name,
'repo_type': REPO_TYPE['ansible_collection'],
'repo_type': REPO_TYPE['ansible_collection'].replace('_', ' '),
'repo_content.requirements': requirements,
'repo_content.upstream_url': ANSIBLE_GALAXY,
},
Expand Down

0 comments on commit edb6958

Please sign in to comment.