From d33cf3317d556488be344f5672501b6b7123630b Mon Sep 17 00:00:00 2001 From: Jan Larwig Date: Tue, 7 Jan 2025 12:12:53 +0100 Subject: [PATCH] feat: allow for configuring the docker hub url via the API Signed-off-by: Jan Larwig --- src/pkg/reg/adapter/dockerhub/adapter.go | 7 +++++++ src/pkg/reg/adapter/dockerhub/consts.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pkg/reg/adapter/dockerhub/adapter.go b/src/pkg/reg/adapter/dockerhub/adapter.go index 821bc4808b2..fe99b577a46 100644 --- a/src/pkg/reg/adapter/dockerhub/adapter.go +++ b/src/pkg/reg/adapter/dockerhub/adapter.go @@ -46,6 +46,13 @@ func newAdapter(registry *model.Registry) (adp.Adapter, error) { return nil, err } + var registryURL string + if registry.URL != baseURL { + registryURL = registry.URL + } else { + registryURL = defaultRegistryURL + } + return &adapter{ client: client, registry: registry, diff --git a/src/pkg/reg/adapter/dockerhub/consts.go b/src/pkg/reg/adapter/dockerhub/consts.go index 6b466805401..d7af5f50dbd 100644 --- a/src/pkg/reg/adapter/dockerhub/consts.go +++ b/src/pkg/reg/adapter/dockerhub/consts.go @@ -18,7 +18,7 @@ import "fmt" const ( baseURL = "https://hub.docker.com" - registryURL = "https://registry-1.docker.io" + defaultRegistryURL = "https://registry-1.docker.io" loginPath = "/v2/users/login/" listNamespacePath = "/v2/repositories/namespaces" createNamespacePath = "/v2/orgs/"