Skip to content

Commit 70148c6

Browse files
nejchJohnVillalovos
authored andcommitted
feat(groups): add support for group-level registry repositories
1 parent c84379d commit 70148c6

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

docs/gl_objects/repositories.rst

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Get the list of container registry repositories associated with the project::
2020

2121
repositories = project.repositories.list()
2222

23+
Get the list of all project container registry repositories in a group::
24+
25+
repositories = group.registry_repositories.list()
26+
2327
Delete repository::
2428

2529
project.repositories.delete(id=x)

gitlab/v4/objects/container_registry.py

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from gitlab.mixins import DeleteMixin, ListMixin, ObjectDeleteMixin, RetrieveMixin
77

88
__all__ = [
9+
"GroupRegistryRepositoryManager",
910
"ProjectRegistryRepository",
1011
"ProjectRegistryRepositoryManager",
1112
"ProjectRegistryTag",
@@ -65,3 +66,9 @@ def get(
6566
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
6667
) -> ProjectRegistryTag:
6768
return cast(ProjectRegistryTag, super().get(id=id, lazy=lazy, **kwargs))
69+
70+
71+
class GroupRegistryRepositoryManager(ListMixin, RESTManager):
72+
_path = "/groups/{group_id}/registry/repositories"
73+
_obj_cls = ProjectRegistryRepository
74+
_from_parent_attrs = {"group_id": "id"}

gitlab/v4/objects/groups.py

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from .badges import GroupBadgeManager # noqa: F401
1616
from .boards import GroupBoardManager # noqa: F401
1717
from .clusters import GroupClusterManager # noqa: F401
18+
from .container_registry import GroupRegistryRepositoryManager # noqa: F401
1819
from .custom_attributes import GroupCustomAttributeManager # noqa: F401
1920
from .deploy_tokens import GroupDeployTokenManager # noqa: F401
2021
from .epics import GroupEpicManager # noqa: F401
@@ -77,6 +78,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
7778
packages: GroupPackageManager
7879
projects: GroupProjectManager
7980
pushrules: GroupPushRulesManager
81+
registry_repositories: GroupRegistryRepositoryManager
8082
runners: GroupRunnerManager
8183
subgroups: "GroupSubgroupManager"
8284
variables: GroupVariableManager
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
GitLab API: https://docs.gitlab.com/ee/api/container_registry.html
3+
"""
4+
import pytest
5+
import responses
6+
7+
from gitlab.v4.objects import ProjectRegistryRepository
8+
9+
repositories_content = [
10+
{
11+
"id": 1,
12+
"name": "",
13+
"path": "group/project",
14+
"project_id": 9,
15+
"location": "gitlab.example.com:5000/group/project",
16+
"created_at": "2019-01-10T13:38:57.391Z",
17+
"cleanup_policy_started_at": "2020-01-10T15:40:57.391Z",
18+
},
19+
{
20+
"id": 2,
21+
"name": "releases",
22+
"path": "group/project/releases",
23+
"project_id": 9,
24+
"location": "gitlab.example.com:5000/group/project/releases",
25+
"created_at": "2019-01-10T13:39:08.229Z",
26+
"cleanup_policy_started_at": "2020-08-17T03:12:35.489Z",
27+
},
28+
]
29+
30+
31+
@pytest.fixture
32+
def resp_group_registry_repositories():
33+
with responses.RequestsMock() as rsps:
34+
rsps.add(
35+
method=responses.GET,
36+
url="http://localhost/api/v4/groups/1/registry/repositories",
37+
json=repositories_content,
38+
content_type="application/json",
39+
status=200,
40+
)
41+
yield rsps
42+
43+
44+
def test_list_group_registry_repositories(group, resp_group_registry_repositories):
45+
repositories = group.registry_repositories.list()
46+
assert isinstance(repositories[0], ProjectRegistryRepository)
47+
assert repositories[0].id == 1

0 commit comments

Comments
 (0)