Skip to content

Commit

Permalink
fixed auth on ping endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdjulian committed Sep 15, 2023
1 parent dc34653 commit 87e95b9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ internal class ResponseRetryWithAuthentication(
private val credentials: RegistryCredentials?,
private val fuelManager: FuelManager,
) {

suspend fun <T : Any> retryOnUnauthorized(
responseResult: ResponseResultOf<T>,
deserializer: Deserializable<T>,
Expand Down Expand Up @@ -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<TokenResponse>())
.third
Expand Down

0 comments on commit 87e95b9

Please sign in to comment.