Skip to content

Commit c6dd57c

Browse files
nejchJohnVillalovos
authored andcommitted
fix(runners): fix listing for /runners/all
1 parent 9c5b8d5 commit c6dd57c

File tree

5 files changed

+68
-5
lines changed

5 files changed

+68
-5
lines changed

docs/cli-examples.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,33 @@ Download the artifacts zip archive of a job:
236236
237237
$ gitlab project-job artifacts --id 10 --project-id 1 > artifacts.zip
238238
239+
Runners
240+
-------
241+
242+
List owned runners:
243+
244+
.. code-block:: console
245+
246+
$ gitlab runner list
247+
248+
List owned runners with a filter:
249+
250+
.. code-block:: console
251+
252+
$ gitlab runner list --scope active
253+
254+
List all runners in the GitLab instance (specific and shared):
255+
256+
.. code-block:: console
257+
258+
$ gitlab runner-all list
259+
260+
Get a runner's details:
261+
262+
.. code-block:: console
263+
264+
$ gitlab -v runner get --id 123
265+
239266
Other
240267
-----
241268

docs/gl_objects/runners.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Reference
1919
+ :class:`gitlab.v4.objects.Runner`
2020
+ :class:`gitlab.v4.objects.RunnerManager`
2121
+ :attr:`gitlab.Gitlab.runners`
22+
+ :class:`gitlab.v4.objects.RunnerAll`
23+
+ :class:`gitlab.v4.objects.RunnerAllManager`
24+
+ :attr:`gitlab.Gitlab.runners_all`
2225

2326
* GitLab API: https://docs.gitlab.com/ce/api/runners.html
2427

@@ -41,14 +44,20 @@ for this parameter are:
4144
The returned objects hold minimal information about the runners. Use the
4245
``get()`` method to retrieve detail about a runner.
4346

47+
Runners returned via ``runners_all.list()`` also cannot be manipulated
48+
directly. You will need to use the ``get()`` method to create an editable
49+
object.
50+
4451
::
4552

4653
# List owned runners
4754
runners = gl.runners.list()
48-
# With a filter
55+
56+
# List owned runners with a filter
4957
runners = gl.runners.list(scope='active')
50-
# List all runners, using a filter
51-
runners = gl.runners.all(scope='paused')
58+
59+
# List all runners in the GitLab instance (specific and shared), using a filter
60+
runners = gl.runners_all.list(scope='paused')
5261

5362
Get a runner's detail::
5463

gitlab/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def __init__(
164164
"""See :class:`~gitlab.v4.objects.RegistryRepositoryManager`"""
165165
self.runners = objects.RunnerManager(self)
166166
"""See :class:`~gitlab.v4.objects.RunnerManager`"""
167+
self.runners_all = objects.RunnerAllManager(self)
168+
"""See :class:`~gitlab.v4.objects.RunnerManager`"""
167169
self.settings = objects.ApplicationSettingsManager(self)
168170
"""See :class:`~gitlab.v4.objects.ApplicationSettingsManager`"""
169171
self.appearance = objects.ApplicationAppearanceManager(self)

gitlab/v4/objects/runners.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"RunnerJobManager",
2020
"Runner",
2121
"RunnerManager",
22+
"RunnerAll",
23+
"RunnerAllManager",
2224
"GroupRunner",
2325
"GroupRunnerManager",
2426
"ProjectRunner",
@@ -39,6 +41,7 @@ class RunnerJobManager(ListMixin, RESTManager):
3941

4042
class Runner(SaveMixin, ObjectDeleteMixin, RESTObject):
4143
jobs: RunnerJobManager
44+
_repr_attr = "description"
4245

4346

4447
class RunnerManager(CRUDMixin, RESTManager):
@@ -68,7 +71,7 @@ class RunnerManager(CRUDMixin, RESTManager):
6871
"maximum_timeout",
6972
),
7073
)
71-
_list_filters = ("scope", "tag_list")
74+
_list_filters = ("scope", "type", "status", "paused", "tag_list")
7275
_types = {"tag_list": types.CommaSeparatedListAttribute}
7376

7477
@cli.register_custom_action("RunnerManager", (), ("scope",))
@@ -121,6 +124,17 @@ def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Runner:
121124
return cast(Runner, super().get(id=id, lazy=lazy, **kwargs))
122125

123126

127+
class RunnerAll(RESTObject):
128+
_repr_attr = "description"
129+
130+
131+
class RunnerAllManager(ListMixin, RESTManager):
132+
_path = "/runners/all"
133+
_obj_cls = RunnerAll
134+
_list_filters = ("scope", "type", "status", "paused", "tag_list")
135+
_types = {"tag_list": types.CommaSeparatedListAttribute}
136+
137+
124138
class GroupRunner(RESTObject):
125139
pass
126140

tests/unit/objects/test_runners.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import responses
55

66
import gitlab
7+
from gitlab.v4.objects.runners import Runner, RunnerAll
78

89
runner_detail = {
910
"active": True,
@@ -233,8 +234,18 @@ def test_group_runners_list(gl: gitlab.Gitlab, resp_get_runners_list):
233234
assert len(runners) == 1
234235

235236

236-
def test_all_runners_list(gl: gitlab.Gitlab, resp_get_runners_list):
237+
def test_runners_all(gl: gitlab.Gitlab, resp_get_runners_list):
237238
runners = gl.runners.all()
239+
assert isinstance(runners[0], Runner)
240+
assert runners[0].active is True
241+
assert runners[0].id == 6
242+
assert runners[0].name == "test-name"
243+
assert len(runners) == 1
244+
245+
246+
def test_runners_all_list(gl: gitlab.Gitlab, resp_get_runners_list):
247+
runners = gl.runners_all.list()
248+
assert isinstance(runners[0], RunnerAll)
238249
assert runners[0].active is True
239250
assert runners[0].id == 6
240251
assert runners[0].name == "test-name"

0 commit comments

Comments
 (0)