Skip to content

Commit b15fc0c

Browse files
committed
feat(private-registry): add API versioning support for private registry requests
1 parent 99af94b commit b15fc0c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

github/private_registries.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (s *PrivateRegistriesService) ListOrganizationPrivateRegistries(ctx context
218218
return nil, nil, err
219219
}
220220

221-
req, err := s.client.NewRequest("GET", u, nil)
221+
req, err := s.client.NewRequest("GET", u, nil, WithVersion("2026-03-10"))
222222
if err != nil {
223223
return nil, nil, err
224224
}
@@ -239,7 +239,7 @@ func (s *PrivateRegistriesService) ListOrganizationPrivateRegistries(ctx context
239239
func (s *PrivateRegistriesService) CreateOrganizationPrivateRegistry(ctx context.Context, org string, privateRegistry CreateOrganizationPrivateRegistry) (*PrivateRegistry, *Response, error) {
240240
u := fmt.Sprintf("orgs/%v/private-registries", org)
241241

242-
req, err := s.client.NewRequest("POST", u, privateRegistry)
242+
req, err := s.client.NewRequest("POST", u, privateRegistry, WithVersion("2026-03-10"))
243243
if err != nil {
244244
return nil, nil, err
245245
}
@@ -260,7 +260,7 @@ func (s *PrivateRegistriesService) CreateOrganizationPrivateRegistry(ctx context
260260
func (s *PrivateRegistriesService) GetOrganizationPrivateRegistriesPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) {
261261
u := fmt.Sprintf("orgs/%v/private-registries/public-key", org)
262262

263-
req, err := s.client.NewRequest("GET", u, nil)
263+
req, err := s.client.NewRequest("GET", u, nil, WithVersion("2026-03-10"))
264264
if err != nil {
265265
return nil, nil, err
266266
}
@@ -282,7 +282,7 @@ func (s *PrivateRegistriesService) GetOrganizationPrivateRegistriesPublicKey(ctx
282282
func (s *PrivateRegistriesService) GetOrganizationPrivateRegistry(ctx context.Context, org, secretName string) (*PrivateRegistry, *Response, error) {
283283
u := fmt.Sprintf("orgs/%v/private-registries/%v", org, secretName)
284284

285-
req, err := s.client.NewRequest("GET", u, nil)
285+
req, err := s.client.NewRequest("GET", u, nil, WithVersion("2026-03-10"))
286286
if err != nil {
287287
return nil, nil, err
288288
}
@@ -305,7 +305,7 @@ func (s *PrivateRegistriesService) GetOrganizationPrivateRegistry(ctx context.Co
305305
func (s *PrivateRegistriesService) UpdateOrganizationPrivateRegistry(ctx context.Context, org, secretName string, privateRegistry UpdateOrganizationPrivateRegistry) (*Response, error) {
306306
u := fmt.Sprintf("orgs/%v/private-registries/%v", org, secretName)
307307

308-
req, err := s.client.NewRequest("PATCH", u, privateRegistry)
308+
req, err := s.client.NewRequest("PATCH", u, privateRegistry, WithVersion("2026-03-10"))
309309
if err != nil {
310310
return nil, err
311311
}
@@ -322,7 +322,7 @@ func (s *PrivateRegistriesService) UpdateOrganizationPrivateRegistry(ctx context
322322
func (s *PrivateRegistriesService) DeleteOrganizationPrivateRegistry(ctx context.Context, org, secretName string) (*Response, error) {
323323
u := fmt.Sprintf("orgs/%v/private-registries/%v", org, secretName)
324324

325-
req, err := s.client.NewRequest("DELETE", u, nil)
325+
req, err := s.client.NewRequest("DELETE", u, nil, WithVersion("2026-03-10"))
326326
if err != nil {
327327
return nil, err
328328
}

github/private_registries_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestPrivateRegistriesService_ListOrganizationPrivateRegistries(t *testing.T
2222

2323
mux.HandleFunc("/orgs/o/private-registries", func(w http.ResponseWriter, r *http.Request) {
2424
testMethod(t, r, "GET")
25+
testHeader(t, r, "X-Github-Api-Version", "2026-03-10")
2526
testFormValues(t, r, values{
2627
"page": "2",
2728
})
@@ -104,6 +105,7 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T
104105
assertNilError(t, json.NewDecoder(r.Body).Decode(&v))
105106

106107
testMethod(t, r, "POST")
108+
testHeader(t, r, "X-Github-Api-Version", "2026-03-10")
107109
if !cmp.Equal(v, input) {
108110
t.Errorf("Request body = %+v, want %+v", v, input)
109111
}
@@ -174,6 +176,7 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDC(t *test
174176
assertNilError(t, json.NewDecoder(r.Body).Decode(&v))
175177

176178
testMethod(t, r, "POST")
179+
testHeader(t, r, "X-Github-Api-Version", "2026-03-10")
177180
if !cmp.Equal(v, input) {
178181
t.Errorf("Request body = %+v, want %+v", v, input)
179182
}
@@ -228,6 +231,7 @@ func TestPrivateRegistries_UpdateOrganizationPrivateRegistry_OIDC(t *testing.T)
228231
assertNilError(t, json.NewDecoder(r.Body).Decode(&v))
229232

230233
testMethod(t, r, "PATCH")
234+
testHeader(t, r, "X-Github-Api-Version", "2026-03-10")
231235
if !cmp.Equal(v, input) {
232236
t.Errorf("Request body = %+v, want %+v", v, input)
233237
}
@@ -261,6 +265,7 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDCJFrog(t
261265
assertNilError(t, json.NewDecoder(r.Body).Decode(&v))
262266

263267
testMethod(t, r, "POST")
268+
testHeader(t, r, "X-Github-Api-Version", "2026-03-10")
264269
if !cmp.Equal(v, input) {
265270
t.Errorf("Request body = %+v, want %+v", v, input)
266271
}
@@ -299,6 +304,7 @@ func TestPrivateRegistriesService_GetOrganizationPrivateRegistriesPublicKey(t *t
299304

300305
mux.HandleFunc("/orgs/o/private-registries/public-key", func(w http.ResponseWriter, r *http.Request) {
301306
testMethod(t, r, "GET")
307+
testHeader(t, r, "X-Github-Api-Version", "2026-03-10")
302308
fmt.Fprint(w, `{
303309
"key_id": "0123456789",
304310
"key": "public_key"
@@ -339,6 +345,7 @@ func TestPrivateRegistriesService_GetOrganizationPrivateRegistry(t *testing.T) {
339345

340346
mux.HandleFunc("/orgs/o/private-registries/MAVEN_REPOSITORY_SECRET", func(w http.ResponseWriter, r *http.Request) {
341347
testMethod(t, r, "GET")
348+
testHeader(t, r, "X-Github-Api-Version", "2026-03-10")
342349
fmt.Fprint(w, `{
343350
"name": "MAVEN_REPOSITORY_SECRET",
344351
"registry_type": "maven_repository",
@@ -396,6 +403,7 @@ func TestPrivateRegistries_UpdateOrganizationPrivateRegistry(t *testing.T) {
396403
assertNilError(t, json.NewDecoder(r.Body).Decode(&v))
397404

398405
testMethod(t, r, "PATCH")
406+
testHeader(t, r, "X-Github-Api-Version", "2026-03-10")
399407
if !cmp.Equal(v, input) {
400408
t.Errorf("Request body = %+v, want %+v", v, input)
401409
}
@@ -426,6 +434,7 @@ func TestPrivateRegistriesService_DeleteOrganizationPrivateRegistry(t *testing.T
426434

427435
mux.HandleFunc("/orgs/o/private-registries/MAVEN_REPOSITORY_SECRET", func(w http.ResponseWriter, r *http.Request) {
428436
testMethod(t, r, "DELETE")
437+
testHeader(t, r, "X-Github-Api-Version", "2026-03-10")
429438
w.WriteHeader(http.StatusNoContent)
430439
})
431440
ctx := t.Context()

0 commit comments

Comments
 (0)