From aa59b0f5a28487288cc11038ce99f0edc06af69c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 29 Aug 2023 10:47:29 +0200 Subject: [PATCH] registry: improve error for invalid search endpoints Explain that search is not supported on v2 endpoints, and include the offending endpoint in the error-message. Signed-off-by: Sebastiaan van Stijn --- registry/endpoint_test.go | 2 +- registry/endpoint_v1.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/endpoint_test.go b/registry/endpoint_test.go index 9afbe54895..654371a696 100644 --- a/registry/endpoint_test.go +++ b/registry/endpoint_test.go @@ -42,7 +42,7 @@ func TestV1EndpointParse(t *testing.T) { }, { address: "https://0.0.0.0:5000/v2/", - expectedErr: "unsupported V1 version path v2", + expectedErr: "search is not supported on v2 endpoints: https://0.0.0.0:5000/v2/", }, } for _, tc := range tests { diff --git a/registry/endpoint_v1.go b/registry/endpoint_v1.go index 65f4824e17..1fdf659ae0 100644 --- a/registry/endpoint_v1.go +++ b/registry/endpoint_v1.go @@ -87,7 +87,7 @@ func validateEndpoint(endpoint *v1Endpoint) error { func trimV1Address(address string) (string, error) { trimmed := strings.TrimSuffix(address, "/") if strings.HasSuffix(trimmed, "/v2") { - return "", invalidParamf("unsupported V1 version path v2") + return "", invalidParamf("search is not supported on v2 endpoints: %s", address) } return strings.TrimSuffix(trimmed, "/v1"), nil }