From 87e95b9ebc3aa79700c23c1b943bb829c54b42fe Mon Sep 17 00:00:00 2001 From: Julian Goede Date: Fri, 15 Sep 2023 10:33:33 +0200 Subject: [PATCH] fixed auth on ping endpoint --- .../kirc/client/SuspendingContainerImageClientFactory.kt | 2 +- .../kotlin/de/cmdjulian/kirc/impl/ContainerRegistryApiImpl.kt | 2 +- .../de/cmdjulian/kirc/impl/ResponseRetryWithAuthentication.kt | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/client/SuspendingContainerImageClientFactory.kt b/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/client/SuspendingContainerImageClientFactory.kt index 73cf2b6..312c78b 100644 --- a/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/client/SuspendingContainerImageClientFactory.kt +++ b/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/client/SuspendingContainerImageClientFactory.kt @@ -14,7 +14,7 @@ import java.time.Duration object SuspendingContainerImageClientFactory { - const val DOCKER_HUB_REGISTRY_URL = "https://registry.hub.docker.com" + const val DOCKER_HUB_REGISTRY_URL = "https://registry.hub.docker.com/" /** * Create a ContainerRegistryClient for a registry. If no args are supplied the client is constructed for Docker diff --git a/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/impl/ContainerRegistryApiImpl.kt b/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/impl/ContainerRegistryApiImpl.kt index 3841cb3..be3259c 100644 --- a/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/impl/ContainerRegistryApiImpl.kt +++ b/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/impl/ContainerRegistryApiImpl.kt @@ -36,7 +36,7 @@ internal class ContainerRegistryApiImpl(private val fuelManager: FuelManager, cr private val handler = ResponseRetryWithAuthentication(credentials, fuelManager) - override suspend fun ping(): Result<*, FuelError> = fuelManager.get("/") + override suspend fun ping(): Result<*, FuelError> = fuelManager.get("/v2/") .awaitResponseResult(EmptyDeserializer) .let { responseResult -> handler.retryOnUnauthorized(responseResult, EmptyDeserializer) } .third diff --git a/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/impl/ResponseRetryWithAuthentication.kt b/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/impl/ResponseRetryWithAuthentication.kt index 3f5f775..e9dd83e 100644 --- a/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/impl/ResponseRetryWithAuthentication.kt +++ b/kirc-suspending/src/main/kotlin/de/cmdjulian/kirc/impl/ResponseRetryWithAuthentication.kt @@ -18,7 +18,6 @@ internal class ResponseRetryWithAuthentication( private val credentials: RegistryCredentials?, private val fuelManager: FuelManager, ) { - suspend fun retryOnUnauthorized( responseResult: ResponseResultOf, deserializer: Deserializable, @@ -61,7 +60,7 @@ internal class ResponseRetryWithAuthentication( if (scope != null) add("scope" to scope) if (service != null) add("service" to service) } - val token = FuelManager.instance.get(realm, parameters) + val token = fuelManager.get(realm, parameters) .let { credentials?.run { AuthenticatedRequest(it).basic(username, password) } ?: it } .awaitResponseResult(jacksonDeserializer()) .third