Skip to content

Commit d43e617

Browse files
committed
registry: deprecate APIEndpoint.Version and APIVersion type
This field was used when the code supported both "v1" and "v2" registries. We no longer support v1 registries, and the only v1 endpoint that's still used is for the legacy "search" endpoint, which does not use the APIEndpoint type. As no code is using this field, and the value will always be set to "v2", we can deprecated the Version field. I'm keeping this field for 1 release, to give notice to any potential external consumer, after which we can delete it. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 69c19cf commit d43e617

6 files changed

Lines changed: 10 additions & 11 deletions

File tree

distribution/pull_v2_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ func testNewPuller(t *testing.T, rawurl string) *puller {
331331
endpoint := registry.APIEndpoint{
332332
Mirror: false,
333333
URL: uri,
334-
Version: registry.APIVersion2,
335334
Official: false,
336335
TrimHostname: false,
337336
TLSConfig: nil,

distribution/push_v2_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,8 @@ func TestWhenEmptyAuthConfig(t *testing.T) {
534534
endpoint: registrypkg.APIEndpoint{
535535
URL: &url.URL{
536536
Scheme: "https",
537-
Host: "index.docker.io",
537+
Host: registrypkg.IndexHostname,
538538
},
539-
Version: registrypkg.APIVersion2,
540539
TrimHostname: true,
541540
},
542541
}

distribution/registry_unit_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func testTokenPassThru(t *testing.T, ts *httptest.Server) {
4343
endpoint := registrypkg.APIEndpoint{
4444
Mirror: false,
4545
URL: uri,
46-
Version: registrypkg.APIVersion2,
4746
Official: false,
4847
TrimHostname: false,
4948
TLSConfig: nil,

registry/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (s *Service) ResolveRepository(name reference.Named) (*RepositoryInfo, erro
115115
type APIEndpoint struct {
116116
Mirror bool
117117
URL *url.URL
118-
Version APIVersion
118+
Version APIVersion // Deprecated: v1 registries are deprecated, and endpoints are always v2.
119119
AllowNondistributableArtifacts bool
120120
Official bool
121121
TrimHostname bool

registry/service_v2.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ func (s *Service) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, e
2525
}
2626
endpoints = append(endpoints, APIEndpoint{
2727
URL: mirrorURL,
28-
Version: APIVersion2,
28+
Version: APIVersion2, //nolint:staticcheck // ignore SA1019 (Version is deprecated) to allow potential consumers to transition.
2929
Mirror: true,
3030
TrimHostname: true,
3131
TLSConfig: mirrorTLSConfig,
3232
})
3333
}
3434
endpoints = append(endpoints, APIEndpoint{
3535
URL: DefaultV2Registry,
36-
Version: APIVersion2,
36+
Version: APIVersion2, //nolint:staticcheck // ignore SA1019 (Version is deprecated) to allow potential consumers to transition.
3737
Official: true,
3838
TrimHostname: true,
3939
TLSConfig: tlsconfig.ServerDefault(),
@@ -55,7 +55,7 @@ func (s *Service) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, e
5555
Scheme: "https",
5656
Host: hostname,
5757
},
58-
Version: APIVersion2,
58+
Version: APIVersion2, //nolint:staticcheck // ignore SA1019 (Version is deprecated) to allow potential consumers to transition.
5959
AllowNondistributableArtifacts: ana,
6060
TrimHostname: true,
6161
TLSConfig: tlsConfig,
@@ -68,7 +68,7 @@ func (s *Service) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, e
6868
Scheme: "http",
6969
Host: hostname,
7070
},
71-
Version: APIVersion2,
71+
Version: APIVersion2, //nolint:staticcheck // ignore SA1019 (Version is deprecated) to allow potential consumers to transition.
7272
AllowNondistributableArtifacts: ana,
7373
TrimHostname: true,
7474
// used to check if supposed to be secure via InsecureSkipVerify

registry/types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77

88
// APIVersion is an integral representation of an API version (presently
99
// either 1 or 2)
10+
//
11+
// Deprecated: v1 registries are deprecated, and endpoints are always v2.
1012
type APIVersion int
1113

1214
func (av APIVersion) String() string {
@@ -15,8 +17,8 @@ func (av APIVersion) String() string {
1517

1618
// API Version identifiers.
1719
const (
18-
APIVersion1 APIVersion = 1
19-
APIVersion2 APIVersion = 2
20+
APIVersion1 APIVersion = 1 // Deprecated: v1 registries are deprecated, and endpoints are always v2.
21+
APIVersion2 APIVersion = 2 // Deprecated: v1 registries are deprecated, and endpoints are always v2.
2022
)
2123

2224
var apiVersions = map[APIVersion]string{

0 commit comments

Comments
 (0)