ContainerManager::copy(): Copy files or folders from a container to a tar stream - #89
ContainerManager::copy(): Copy files or folders from a container to a tar stream#89Boran wants to merge 9 commits into
Conversation
|
Sweet feature..will try this soon! |
There was a problem hiding this comment.
You can skip the double quotes around $resource here
|
Sweet indeed! I have a couple questions/remarks before merging though:
|
There was a problem hiding this comment.
Missing variable type here, I assume it would be string? Maybe you could rename the argument too, because $resource is misleading if it can't be an actual resource. What about $source?
|
@ubermuda about 1.: It’s a |
There was a problem hiding this comment.
@return \Guzzle\Stream\Stream Tarfile stream would be more accurate and allows for autocompletion.
|
Ok I misread the title, I was thinking it was meant to copy files to the container, not from. It's all clear now thanks :) |
|
@Boran I think it makes sense to add an additional helper method containing the example code..something like public function copyToDisk(Container $container, $source, $destination)
{
$stream = $this->copy($container, $source);
$output = fopen($destination, 'w+');
stream_copy_to_stream($stream->detach(), $output);
fclose($output);
return $this;
} |
+1 |
|
Made the comments and code changes. Docs: my master /stage1/docker-php/doc does not have all the stuff from #87, I must check. |
|
Great thanks! #87 has been merged btw :) |
|
Is there doc explaining how to run tests? |
|
Running |
|
Well I'm not used to phpunit. I installed it and then tried: cd /var/www/html/sites/all/libraries/composer/stage1/docker-php Then tried in the directory where the autoload.php is... phpunit stage1/docker-php/src/Docker/Tests/ContainerTest.php Any tips? |
|
@Boran Go to your docker-php dir ( |
|
Tested it one more time..works like a charm! Thanks @Boran ...that’s a very important feature! |
|
So test written and working: Starting test 'Docker\Tests\Manager\ContainerManagerTest::testcopyToDisk'. A quick note on how to run tests: cd /var/www/html/sites/all/libraries/composer/stage1/docker-php Also: didn't find a way of running just one test function, e.g. testcopyToDisk(), which makes developing the test a bit more time consuming, is there a way? (Tried --filter 'Docker\Tests\Manager\ContainerManagerTest::testCreate', but that is ignored) |
|
@Boran Had the same problem last week :) Try: |
|
Thanks, '--filter' works nicely: phpunit --debug --bootstrap /var/www/html/sites/all/libraries/composer/autoload.php --filter testCopyToDisk ContainerManagerTest src/Docker/Tests/Manager/ContainerManagerTest.php |
There was a problem hiding this comment.
- Function, file and directory names should be enclosed with backticks (`)
- Add an
sto the first File (first word in paragraph)
|
I think I got all your suggestions in? |
|
@Boran Looks good, can you rebase the PR into a single commit before merging ? Thanks ! |
|
After trying to rebase and solve merge conflicts with master, am giving up on this branch. Created a new file-copy2 branch and PR #109. |
Api for http://docs.docker.com/reference/api/docker_remote_api_v1.16/#copy-files-or-folders-from-a-container
Example usage