@@ -18,6 +18,7 @@ import de.gesellix.docker.engine.RequestMethod.POST
1818import de.gesellix.docker.remote.api.BuildInfo
1919import de.gesellix.docker.remote.api.BuildPruneResponse
2020import de.gesellix.docker.remote.api.ContainerConfig
21+ import de.gesellix.docker.remote.api.CreateImageInfo
2122import de.gesellix.docker.remote.api.HistoryResponseItem
2223import de.gesellix.docker.remote.api.IdResponse
2324import de.gesellix.docker.remote.api.Image
@@ -571,6 +572,7 @@ class ImageApi(dockerClientConfig: DockerClientConfig = defaultClientConfig, pro
571572 * @throws ServerException If the API returns a server error response
572573 */
573574 @Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
575+ @JvmOverloads
574576 fun imageCreate (
575577 fromImage : String? ,
576578 fromSrc : String? ,
@@ -580,7 +582,8 @@ class ImageApi(dockerClientConfig: DockerClientConfig = defaultClientConfig, pro
580582 xRegistryAuth : String? ,
581583 changes : List <String >? ,
582584 platform : String? ,
583- inputImage : InputStream ?
585+ inputImage : InputStream ? ,
586+ callback : StreamCallback <CreateImageInfo ?>? = null, timeoutMillis : Long? = null /* = 24.hours.toLongMilliseconds()*/
584587 ) {
585588 val localVariableConfig =
586589 imageCreateRequestConfig(
@@ -595,21 +598,25 @@ class ImageApi(dockerClientConfig: DockerClientConfig = defaultClientConfig, pro
595598 inputImage = inputImage
596599 )
597600
598- val localVarResponse = requestStream<Any ?>(
601+ val localVarResponse = requestStream<CreateImageInfo ?>(
599602 localVariableConfig
600603 )
601604
602- val timeout = Duration .of(1 , ChronoUnit .MINUTES )
603- val callback = LoggingCallback <Any >()
605+ val timeout = if (timeoutMillis == null ) {
606+ Duration .of(10 , ChronoUnit .MINUTES )
607+ } else {
608+ Duration .of(timeoutMillis, ChronoUnit .MILLIS )
609+ }
610+ val actualCallback = callback ? : LoggingCallback <CreateImageInfo ?>()
604611
605612 return when (localVarResponse.responseType) {
606613 ResponseType .Success -> {
607614 runBlocking {
608615 launch {
609616 withTimeout(timeout.toMillis()) {
610- callback .onStarting(this @launch::cancel)
611- (localVarResponse as SuccessStream <* >).data.collect { callback .onNext(it) }
612- callback .onFinished()
617+ actualCallback .onStarting(this @launch::cancel)
618+ (( localVarResponse as SuccessStream <* >).data as Flow < CreateImageInfo ?>) .collect { actualCallback .onNext(it) }
619+ actualCallback .onFinished()
613620 }
614621 }
615622 }
0 commit comments