Skip to content

Commit b7d9563

Browse files
committed
Remove deprecated containerCopy() and containerCopyStream() methods
Use `containerArchive()` and `containerArchiveStream()` instead.
1 parent 746b9cb commit b7d9563

File tree

3 files changed

+3
-104
lines changed

3 files changed

+3
-104
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ The following API endpoints resolve with a string in the [TAR file format](https
243243

244244
```php
245245
$client->containerExport($container);
246-
$client->containerCopy($container, $config);
246+
$client->containerArchive($container, $path);
247247
```
248248

249249
Keep in mind that this means the whole string has to be kept in memory.
@@ -257,14 +257,14 @@ a [`Stream`](https://github.com/reactphp/stream) instance instead:
257257

258258
```php
259259
$stream = $client->containerExportStream($image);
260-
$stream = $client->containerCopyStream($image, $config);
260+
$stream = $client->containerArchiveStream($container, $path);
261261
```
262262

263263
Accessing individual files in the TAR file format string or stream is out of scope
264264
for this library.
265265
Several libraries are available, one that is known to work is [clue/reactphp-tar](https://github.com/clue/reactphp-tar).
266266

267-
See also the [copy example](examples/copy.php) and the [export example](examples/export.php).
267+
See also the [archive example](examples/archive.php) and the [export example](examples/export.php).
268268

269269
#### JSON streaming
270270

src/Client.php

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -712,89 +712,6 @@ public function containerRemove($container, $v = false, $force = false)
712712
)->then(array($this->parser, 'expectEmpty'));
713713
}
714714

715-
/**
716-
* [deprecated] Copy files or folders of container id
717-
*
718-
* This resolves with a string in the TAR file format containing all files
719-
* specified in the given $path.
720-
*
721-
* Keep in mind that this means the whole string has to be kept in memory.
722-
* For bigger containers it's usually a better idea to use a streaming approach,
723-
* see containerCopyStream() for more details.
724-
*
725-
* Accessing individual files in the TAR file format string is out of scope
726-
* for this library. Several libraries are available, one that is known to
727-
* work is clue/reactphp-tar (see links).
728-
*
729-
* @param string $container container ID
730-
* @param string $resource path to file or directory to copy
731-
* @return PromiseInterface Promise<string> tar stream
732-
* @link https://docs.docker.com/engine/api/v1.22/#copy-files-or-folders-from-a-container
733-
* @link https://github.com/clue/reactphp-tar
734-
* @deprecated 0.3.0 Deprecated in Docker Engine API v1.20 (Docker v1.8) and removed in Docker Engine API v1.24 (Docker v1.12), use `containerArchive()` instead
735-
* @see self::containerArchive()
736-
* @see self::containerCopyStream()
737-
*/
738-
public function containerCopy($container, $path)
739-
{
740-
return $this->postJson(
741-
$this->uri->expand(
742-
'/containers/{container}/copy',
743-
array(
744-
'container' => $container
745-
)
746-
),
747-
array(
748-
'Resource' => $path
749-
)
750-
)->then(array($this->parser, 'expectPlain'));
751-
}
752-
753-
/**
754-
* [Deprecated] Copy files or folders of container id
755-
*
756-
* This returns a stream in the TAR file format containing all files
757-
* specified in the given $path.
758-
*
759-
* This works for (any number of) files of arbitrary sizes as only small chunks have to
760-
* be kept in memory.
761-
*
762-
* Accessing individual files in the TAR file format stream is out of scope
763-
* for this library. Several libraries are available, one that is known to
764-
* work is clue/reactphp-tar (see links).
765-
*
766-
* The resulting stream is a well-behaving readable stream that will emit
767-
* the normal stream events.
768-
*
769-
* @param string $container container ID
770-
* @param string $path path to file or directory to copy
771-
* @return ReadableStreamInterface tar stream
772-
* @link https://docs.docker.com/engine/api/v1.22/#copy-files-or-folders-from-a-container
773-
* @link https://github.com/clue/reactphp-tar
774-
* @deprecated 0.3.0 Deprecated in Docker Engine API v1.20 (Docker v1.8) and removed in Docker Engine API v1.24 (Docker v1.12), use `containerArchiveStream()` instead
775-
* @see self::containerArchiveStream()
776-
* @see self::containerCopy()
777-
*/
778-
public function containerCopyStream($container, $path)
779-
{
780-
return $this->streamingParser->parsePlainStream(
781-
$this->browser->withOptions(array('streaming' => true))->post(
782-
$this->uri->expand(
783-
'/containers/{container}/copy',
784-
array(
785-
'container' => $container
786-
)
787-
),
788-
array(
789-
'Content-Type' => 'application/json'
790-
),
791-
$this->json(array(
792-
'Resource' => $path
793-
))
794-
)
795-
);
796-
}
797-
798715
/**
799716
* Get a tar archive of a resource in the filesystem of container id.
800717
*

tests/ClientTest.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -417,24 +417,6 @@ public function testContainerResize()
417417
$this->expectPromiseResolveWith('', $this->client->containerResize(123, 800, 600));
418418
}
419419

420-
public function testContainerCopy()
421-
{
422-
$data = 'tar stream';
423-
$this->expectRequestFlow('post', '/containers/123/copy', $this->createResponse($data), 'expectPlain');
424-
425-
$this->expectPromiseResolveWith($data, $this->client->containerCopy('123', 'file.txt'));
426-
}
427-
428-
public function testContainerCopyStream()
429-
{
430-
$stream = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
431-
432-
$this->expectRequest('post', '/containers/123/copy', $this->createResponse(''));
433-
$this->streamingParser->expects($this->once())->method('parsePlainStream')->will($this->returnValue($stream));
434-
435-
$this->assertSame($stream, $this->client->containerCopyStream('123', 'file.txt'));
436-
}
437-
438420
public function testContainerArchive()
439421
{
440422
$data = 'tar stream';

0 commit comments

Comments
 (0)