Skip to content

Commit

Permalink
added timout param
Browse files Browse the repository at this point in the history
fixed keystore not getting set bug on fuel client
  • Loading branch information
cmdjulian committed Jun 24, 2023
1 parent 69870ce commit c9c0800
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import kotlinx.coroutines.runBlocking
import java.net.Proxy
import java.net.URI
import java.security.KeyStore
import java.time.Duration

object BlockingContainerImageClientFactory {

@@ -23,8 +24,9 @@ object BlockingContainerImageClientFactory {
proxy: Proxy? = null,
skipTlsVerify: Boolean = false,
keystore: KeyStore? = null,
timeout: Duration = Duration.ofSeconds(5),
): BlockingContainerImageRegistryClient =
SuspendingContainerImageClientFactory.create(url, credentials, proxy, skipTlsVerify, keystore)
SuspendingContainerImageClientFactory.create(url, credentials, proxy, skipTlsVerify, keystore, timeout)
.toBlockingClient()

@JvmStatic
@@ -36,8 +38,10 @@ object BlockingContainerImageClientFactory {
insecure: Boolean = false,
skipTlsVerify: Boolean = false,
keystore: KeyStore? = null,
timeout: Duration = Duration.ofSeconds(5),
): BlockingContainerImageClient = runBlocking {
SuspendingContainerImageClientFactory.create(image, credentials, proxy, insecure, skipTlsVerify, keystore)
SuspendingContainerImageClientFactory
.create(image, credentials, proxy, insecure, skipTlsVerify, keystore, timeout)
.toBlockingClient()
}
}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import kotlinx.coroutines.runBlocking
import java.net.Proxy
import java.net.URI
import java.security.KeyStore
import java.time.Duration

object ReactiveContainerImageClientFactory {

@@ -23,8 +24,9 @@ object ReactiveContainerImageClientFactory {
proxy: Proxy? = null,
skipTlsVerify: Boolean = false,
keystore: KeyStore? = null,
timeout: Duration = Duration.ofSeconds(5),
): ReactiveContainerImageRegistryClient =
SuspendingContainerImageClientFactory.create(url, credentials, proxy, skipTlsVerify, keystore)
SuspendingContainerImageClientFactory.create(url, credentials, proxy, skipTlsVerify, keystore, timeout)
.toReactiveClient()

@JvmStatic
@@ -36,8 +38,10 @@ object ReactiveContainerImageClientFactory {
insecure: Boolean = false,
skipTlsVerify: Boolean = false,
keystore: KeyStore? = null,
timeout: Duration = Duration.ofSeconds(5),
): ReactiveContainerImageClient = runBlocking {
SuspendingContainerImageClientFactory.create(image, credentials, proxy, insecure, skipTlsVerify, keystore)
SuspendingContainerImageClientFactory
.create(image, credentials, proxy, insecure, skipTlsVerify, keystore, timeout)
.toReactiveClient()
}
}
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import de.cmdjulian.kirc.utils.NoopHostnameVerifier
import java.net.Proxy
import java.net.URI
import java.security.KeyStore
import java.time.Duration

object SuspendingContainerImageClientFactory {

@@ -26,12 +27,17 @@ object SuspendingContainerImageClientFactory {
proxy: Proxy? = null,
skipTlsVerify: Boolean = false,
keystore: KeyStore? = null,
timeout: Duration = Duration.ofSeconds(5),
): SuspendingContainerImageRegistryClient {
require(keystore == null || !skipTlsVerify) { "can not skip tls verify if a keystore is set" }
require(timeout.toMillis() in Int.MIN_VALUE..Int.MAX_VALUE) { "timeout in ms has to be a valid int" }

val fuel = FuelManager().apply {
this.basePath = url.toString()
this.proxy = proxy
this.keystore = keystore
this.timeoutInMillisecond = timeout.toMillis().toInt()
this.timeoutReadInMillisecond = timeout.toMillis().toInt()

if (skipTlsVerify) {
hostnameVerifier = NoopHostnameVerifier
@@ -50,9 +56,10 @@ object SuspendingContainerImageClientFactory {
insecure: Boolean = false,
skipTlsVerify: Boolean = false,
keystore: KeyStore? = null,
timeout: Duration = Duration.ofSeconds(5),
): SuspendingContainerImageClient {
val url = "${if (insecure) "http://" else "https://"}${image.registry}"
val client = create(URI(url), credentials, proxy, skipTlsVerify, keystore)
val client = create(URI(url), credentials, proxy, skipTlsVerify, keystore, timeout)

return SuspendingContainerImageClientImpl(client, image)
}

0 comments on commit c9c0800

Please sign in to comment.