Skip to content

Commit faffd29

Browse files
authored
feat!: Add ListRunnersOptions to support all query parameters (#3094)
Fixes: #3093. BREAKING-CHANGE: This changes `ListOptions` to `ListRunnersOptions` in `ListRunners` and `ListOrganizationRunners`.
1 parent 497dbe8 commit faffd29

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

github/actions_runners.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,18 @@ type Runners struct {
151151
Runners []*Runner `json:"runners"`
152152
}
153153

154+
// ListRunnersOptions specifies the optional parameters to the ListRunners and ListOrganizationRunners methods.
155+
type ListRunnersOptions struct {
156+
Name *string `url:"name,omitempty"`
157+
ListOptions
158+
}
159+
154160
// ListRunners lists all the self-hosted runners for a repository.
155161
//
156162
// GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-a-repository
157163
//
158164
//meta:operation GET /repos/{owner}/{repo}/actions/runners
159-
func (s *ActionsService) ListRunners(ctx context.Context, owner, repo string, opts *ListOptions) (*Runners, *Response, error) {
165+
func (s *ActionsService) ListRunners(ctx context.Context, owner, repo string, opts *ListRunnersOptions) (*Runners, *Response, error) {
160166
u := fmt.Sprintf("repos/%v/%v/actions/runners", owner, repo)
161167
u, err := addOptions(u, opts)
162168
if err != nil {
@@ -290,7 +296,7 @@ func (s *ActionsService) CreateOrganizationRegistrationToken(ctx context.Context
290296
// GitHub API docs: https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-organization
291297
//
292298
//meta:operation GET /orgs/{org}/actions/runners
293-
func (s *ActionsService) ListOrganizationRunners(ctx context.Context, org string, opts *ListOptions) (*Runners, *Response, error) {
299+
func (s *ActionsService) ListOrganizationRunners(ctx context.Context, org string, opts *ListRunnersOptions) (*Runners, *Response, error) {
294300
u := fmt.Sprintf("orgs/%v/actions/runners", org)
295301
u, err := addOptions(u, opts)
296302
if err != nil {

github/actions_runners_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,24 @@ func TestActionsService_ListRunners(t *testing.T) {
188188

189189
mux.HandleFunc("/repos/o/r/actions/runners", func(w http.ResponseWriter, r *http.Request) {
190190
testMethod(t, r, "GET")
191-
testFormValues(t, r, values{"per_page": "2", "page": "2"})
192-
fmt.Fprint(w, `{"total_count":2,"runners":[{"id":23,"name":"MBP","os":"macos","status":"online"},{"id":24,"name":"iMac","os":"macos","status":"offline"}]}`)
191+
testFormValues(t, r, values{"name": "MBP", "per_page": "2", "page": "2"})
192+
fmt.Fprint(w, `{"total_count":1,"runners":[{"id":23,"name":"MBP","os":"macos","status":"online"}]}`)
193193
})
194194

195-
opts := &ListOptions{Page: 2, PerPage: 2}
195+
opts := &ListRunnersOptions{
196+
Name: String("MBP"),
197+
ListOptions: ListOptions{Page: 2, PerPage: 2},
198+
}
196199
ctx := context.Background()
197200
runners, _, err := client.Actions.ListRunners(ctx, "o", "r", opts)
198201
if err != nil {
199202
t.Errorf("Actions.ListRunners returned error: %v", err)
200203
}
201204

202205
want := &Runners{
203-
TotalCount: 2,
206+
TotalCount: 1,
204207
Runners: []*Runner{
205208
{ID: Int64(23), Name: String("MBP"), OS: String("macos"), Status: String("online")},
206-
{ID: Int64(24), Name: String("iMac"), OS: String("macos"), Status: String("offline")},
207209
},
208210
}
209211
if !cmp.Equal(runners, want) {
@@ -413,7 +415,9 @@ func TestActionsService_ListOrganizationRunners(t *testing.T) {
413415
fmt.Fprint(w, `{"total_count":2,"runners":[{"id":23,"name":"MBP","os":"macos","status":"online"},{"id":24,"name":"iMac","os":"macos","status":"offline"}]}`)
414416
})
415417

416-
opts := &ListOptions{Page: 2, PerPage: 2}
418+
opts := &ListRunnersOptions{
419+
ListOptions: ListOptions{Page: 2, PerPage: 2},
420+
}
417421
ctx := context.Background()
418422
runners, _, err := client.Actions.ListOrganizationRunners(ctx, "o", opts)
419423
if err != nil {

github/github-accessors.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)