@@ -24,6 +24,7 @@ import de.gesellix.docker.remote.api.ImageDeleteResponseItem
2424import de.gesellix.docker.remote.api.ImagePruneResponse
2525import de.gesellix.docker.remote.api.ImageSearchResponseItem
2626import de.gesellix.docker.remote.api.ImageSummary
27+ import de.gesellix.docker.remote.api.PushImageInfo
2728import de.gesellix.docker.remote.api.core.ApiClient
2829import de.gesellix.docker.remote.api.core.ClientError
2930import de.gesellix.docker.remote.api.core.ClientException
@@ -33,10 +34,12 @@ import de.gesellix.docker.remote.api.core.RequestConfig
3334import de.gesellix.docker.remote.api.core.ResponseType
3435import de.gesellix.docker.remote.api.core.ServerError
3536import de.gesellix.docker.remote.api.core.ServerException
37+ import de.gesellix.docker.remote.api.core.StreamCallback
3638import de.gesellix.docker.remote.api.core.Success
3739import de.gesellix.docker.remote.api.core.SuccessStream
3840import de.gesellix.docker.remote.api.core.toMultiValue
3941import kotlinx.coroutines.cancel
42+ import kotlinx.coroutines.flow.Flow
4043import kotlinx.coroutines.flow.collect
4144import kotlinx.coroutines.launch
4245import kotlinx.coroutines.runBlocking
@@ -1116,24 +1119,32 @@ class ImageApi(dockerClientConfig: DockerClientConfig = defaultClientConfig, pro
11161119 * @throws ServerException If the API returns a server error response
11171120 */
11181121 @Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
1119- fun imagePush (name : String , xRegistryAuth : String , tag : String? ) {
1122+ @JvmOverloads
1123+ fun imagePush (
1124+ name : String , xRegistryAuth : String , tag : String? ,
1125+ callback : StreamCallback <PushImageInfo ?>? = null, timeoutMillis : Long? = null /* = 24.hours.toLongMilliseconds()*/
1126+ ) {
11201127 val localVariableConfig = imagePushRequestConfig(name = name, xRegistryAuth = xRegistryAuth, tag = tag)
11211128
1122- val localVarResponse = requestStream<Any ?>(
1129+ val localVarResponse = requestStream<PushImageInfo ?>(
11231130 localVariableConfig
11241131 )
11251132
1126- val timeout = Duration .of(10 , ChronoUnit .MINUTES )
1127- val callback = LoggingCallback ()
1133+ val timeout = if (timeoutMillis == null ) {
1134+ Duration .of(10 , ChronoUnit .MINUTES )
1135+ } else {
1136+ Duration .of(timeoutMillis, ChronoUnit .MILLIS )
1137+ }
1138+ val actualCallback = callback ? : LoggingCallback <PushImageInfo ?>()
11281139
11291140 return when (localVarResponse.responseType) {
11301141 ResponseType .Success -> {
11311142 runBlocking {
11321143 launch {
11331144 withTimeout(timeout.toMillis()) {
1134- callback .onStarting(this @launch::cancel)
1135- (localVarResponse as SuccessStream <* >).data.collect { callback .onNext(it) }
1136- callback .onFinished()
1145+ actualCallback .onStarting(this @launch::cancel)
1146+ (( localVarResponse as SuccessStream <* >).data as Flow < PushImageInfo >) .collect { actualCallback .onNext(it) }
1147+ actualCallback .onFinished()
11371148 }
11381149 }
11391150 }
0 commit comments