@@ -414,6 +414,9 @@ public function imageHistory($image)
414414 /**
415415 * Push the image name on the registry
416416 *
417+ * Will resolve with an array of all progress events. These can also be
418+ * accessed via the Promise progress handler.
419+ *
417420 * @param string $image image ID
418421 * @param string|null $tag (optional) the tag to associate with the image on the registry
419422 * @param string|null $registry (optional) the registry to push to (e.g. `registry.acme.com:5000`)
@@ -422,9 +425,37 @@ public function imageHistory($image)
422425 * @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#push-an-image-on-the-registry
423426 */
424427 public function imagePush ($ image , $ tag = null , $ registry = null , $ registryAuth = null )
428+ {
429+ $ stream = $ this ->imagePushStream ($ image , $ tag , $ registry , $ registryAuth );
430+
431+ return $ this ->streamingParser ->deferredStream ($ stream , 'progress ' );
432+ }
433+
434+ /**
435+ * Push the image name on the registry
436+ *
437+ * The resulting stream will emit the following events:
438+ * - progress: for *each* element in the update stream
439+ * - error: once if an error occurs, will close() stream then
440+ * - close: once the stream ends (either finished or after "error")
441+ *
442+ * Please note that the resulting stream does not emit any "data" events, so
443+ * you will not be able to pipe() its events into another `WritableStream`.
444+ *
445+ * @param string $image image ID
446+ * @param string|null $tag (optional) the tag to associate with the image on the registry
447+ * @param string|null $registry (optional) the registry to push to (e.g. `registry.acme.com:5000`)
448+ * @param array|null $registryAuth (optional) AuthConfig object (to send as X-Registry-Auth header)
449+ * @return ReadableStreamInterface stream of image push messages
450+ * @link https://docs.docker.com/reference/api/docker_remote_api_v1.15/#push-an-image-on-the-registry
451+ */
452+ public function imagePushStream ($ image , $ tag = null , $ registry = null , $ registryAuth = null )
425453 {
426454 $ path = '/images ' . ($ registry === null ? '' : ('/ ' . $ registry )) . '/%s/push?tag=%s ' ;
427- return $ this ->browser ->post ($ this ->url ($ path , $ image , $ tag ), $ this ->authHeaders ($ registryAuth ))->then (array ($ this ->parser , 'expectJson ' ));
455+
456+ return $ this ->streamingParser ->parseJsonStream (
457+ $ this ->browser ->post ($ this ->url ($ path , $ image , $ tag ), $ this ->authHeaders ($ registryAuth ))
458+ );
428459 }
429460
430461 /**
0 commit comments