X Tutup
Skip to content

Implementation of copy archive to/from container commands#347

Merged
marcuslinke merged 15 commits intodocker-java:masterfrom
vuminhkh:master
Dec 8, 2015
Merged

Implementation of copy archive to/from container commands#347
marcuslinke merged 15 commits intodocker-java:masterfrom
vuminhkh:master

Conversation

@vuminhkh
Copy link
Copy Markdown
Contributor

Hello,

I've implemented "Copy file to container command", but it seems that migrating to 1.20 API breaks other part (8 tests failure). The commands that I modified, the test works well.

As I don't have enough knowledge of the project to fix them all, I still perform the pull request, hoping that it will be useful.

Thanks,

Minh Khang VU

Modification of Copy file from container command to follow 1.20 API
@marcuslinke
Copy link
Copy Markdown
Contributor

@vuminhkh Thanks for your contribution. I will merge ASAP.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place in try-with-resources?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. It's better to go with new Java 7 functionality. It's cleaner.

@KostyaSha
Copy link
Copy Markdown
Member

I see many unclosed streams, @vuminhkh could you check that you have no resource leaks https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html ?

@vuminhkh
Copy link
Copy Markdown
Contributor Author

Hello,

For streams unclosed, if i'm not mistaken it's about the tar method in CompressArchiveUtil, as it's stream which wrap stream, closing the most outer will delegate to inner and the whole stream chain will be closed.

For formatting rules, i'm using Intellij, please feel free to re-organize based on your IDE settings, or give me some hints to have the same format rules as yours.

Thanks,

Minh Khang VU

* master:
  Update CHANGELOG.md
  issue #349
* master: (21 commits)
  Update CHANGELOG.md
  Format sources
  Update CHANGELOG.md
  Update CHANGELOG.md
  Added missing withXXX(List list) methods
  Update README.md
  Bump to version 3.0.0-SNAPSHOT according to semver
  Update CHANGELOG.md
  Added override for bulk-read variant of InputStream.read() in anonymous inner class created by Dockerfile.ScannedResult.buildDockerFolderTar(). This fixes an IO performance issue that occurs when only the single-byte variant of the read() method on InputStream is overriden.
  Added @checkfornull annotation
  Update README.md
  Update CHANGELOG.md
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release docker-java-2.1.2
  Fix issue #348
  Small doc fixes
  Removed import
  Added additional withX(List<Y> x) methods
  Added null check annotations and removed withX() methods
  WIP
  ...

Conflicts:
	src/main/java/com/github/dockerjava/core/command/CopyFileFromContainerCmdImpl.java
@marcuslinke
Copy link
Copy Markdown
Contributor

@vuminhkh After thinking about again we should stay backward compatible. In fact the CopyFileFromContainerCmd should target to /containers/{id}/copy and then
a new CopyArchiveFromContainerCmd as well as a CopyArchiveToContainerCmd should target to /containers/{id}/archive. Would it be possible for you to change your PR accordingly please?

@vuminhkh
Copy link
Copy Markdown
Contributor Author

Hi Marcus,

I'll find my-self some times to do this asap.

Minh Khang VU

* master:
  Fix DockerClientConfig serialization.
  Move findbugs into profile.
  Add checkstyle with unused imports check
  Move utils into util package
  Remove unused imports
  Make util contstructors private
  Move exceptions into separate package

Conflicts:
	src/main/java/com/github/dockerjava/core/command/CopyFileFromContainerCmdImpl.java
	src/main/java/com/github/dockerjava/jaxrs/DockerCmdExecFactoryImpl.java
…hiveFromContainerCmd and CopyArchiveToContainerCmd
@vuminhkh
Copy link
Copy Markdown
Contributor Author

Hi Marcus,

Please review to see if it's ok. There are always 8 test failures (the same as before) but they don't concern the commands that I added/modified.

Regards,

Minh Khang VU
TestSuite.txt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add javadoc and mention from what docker-api version it works.

@KostyaSha
Copy link
Copy Markdown
Member

@vuminhkh please exclude all unrelated to your change formatting and import changes

* master:
  Fix potential NullpointerExceptions
  Fix changelog
  Renamed networStats to network
  Remove "Stats" from "networks" field in statistics
  Improve JavaDoc and include @checkfornull
  Deprecate "network" and enable "networks" stats (remote Docker API 1.21)
@vuminhkh
Copy link
Copy Markdown
Contributor Author

@KostyaSha I tried to use your formatting rules at docker-java/etc/code-style.epf and eclipse plugin for intellij, it seems that i's not your current formatting rules. So I made all the changes "manually", what do you advice about formatting rules in order to contribute to your project ?

@marcuslinke
Copy link
Copy Markdown
Contributor

@vuminhkh Thanks! Hopefully I'm able to merge this evening...

@marcuslinke
Copy link
Copy Markdown
Contributor

@vuminhkh After looking deeper into this I've just found that the API of CopyArchiveToContainerCmd prevents from copying an already compressed tar archive to the container. This is useful if someone wants to copy an archive from one container to another one.

The command should be able to transport a InputStream to the CopyArchiveToContainerCmdExec just like the BuildImageCmd does. The tar compression must be done in the command and not in the exec class then. Would it be possible for you to adopt your PR accordingly please?

Beside this, the NullpointerExceptions that you got are caused by #388

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deprecated javadoc

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change

* master:
  Added @nonnull annotations
  Pass mandatory container id into stats command constructor
  Update CHANGELOG.md
  Remove public from members as getters are public already
  Allow legacy registry message to indicate pull success
  Allow legacy registry message to indicate pull success
  Make ProgressDetails attributes public
  Update CHANGELOG.md
  Update CHANGELOG.md
  Add equals and hashCode for State
  Add test case
  Add missing properties for InspectContainerResponse.Status
  Add docker versions for easier javadoc reference

Conflicts:
	src/main/java/com/github/dockerjava/api/DockerClient.java
@vuminhkh
Copy link
Copy Markdown
Contributor Author

vuminhkh commented Dec 3, 2015

@marcuslinke I agree with you, It's not much modification but the API is more generic. I updated the API according to your suggestion.
@KostyaSha API doc and deprecated annotation updated to Java standard. For indentation issues, I insist that you commit your formatting rules and I'll use it to reformat files that I modified.

Thanks,

Minh Khang VU

@KostyaSha
Copy link
Copy Markdown
Member

@vuminhkh i slowly adding checkstyle that matches to what marcus did. The standard rule for projects that has not yet defined styles is not mix styles and follow existed. And exclude unrelated to change changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not critical, but for simplification there are API versions for linking javadocs. Example

)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try change link to version here also

@vuminhkh
Copy link
Copy Markdown
Contributor Author

vuminhkh commented Dec 5, 2015

@KostyaSha updated javadoc following your hint.
@marcuslinke and @KostyaSha I began to implement new network API, you can preview at https://github.com/vuminhkh/docker-java/tree/network . I'll perform another pull request once this one merged.

Thanks,

Minh Khang VU

@KostyaSha
Copy link
Copy Markdown
Member

@vuminhkh implement classes is pretty simple, problem is wrote tests and verify this changes.

@vuminhkh
Copy link
Copy Markdown
Contributor Author

vuminhkh commented Dec 5, 2015

@KostyaSha For commands that I implemented, if i'm not mistaken, I've written tests for them all. Normally what I wrote did not break any existing feature, tests that are broken were APIs which are not compatible anymore with newer Docker API. I have not fixed those tests yet, I'll do it once I have more time. If you guy could help me also on this it will be great as I don't have knowledge about those existing command.

@vuminhkh
Copy link
Copy Markdown
Contributor Author

vuminhkh commented Dec 5, 2015

@marcuslinke @KostyaSha For breaking changes in docker API, what will be your strategy to be compatible with multiple docker api version ?

@KostyaSha
Copy link
Copy Markdown
Member

Depends on cases.

2015-12-05 21:45 GMT+03:00 vuminhkh notifications@github.com:

@marcuslinke https://github.com/marcuslinke @KostyaSha
https://github.com/KostyaSha For breaking changes in docker API, what
will be your strategy to be compatible with multiple docker api version ?


Reply to this email directly or view it on GitHub
#347 (comment)
.

@vuminhkh
Copy link
Copy Markdown
Contributor Author

vuminhkh commented Dec 5, 2015

@KostyaSha What is the configuration of your test ? Which version of docker do you target to assure that there's not regression ? If i'm not mistaken it's here https://github.com/docker-java/docker-java/blob/master/src/test/java/com/github/dockerjava/client/AbstractDockerClientTest.java#L41 that you define which version of API the test target. Is it ok if I change it to 1.21 ?

@KostyaSha
Copy link
Copy Markdown
Member

I'm bit newbie with current tests design. @marcuslinke please suggest.

@marcuslinke
Copy link
Copy Markdown
Contributor

@vuminhkh, @KostyaSha Currently we can only test against one specific version of the remote API. This is also the reason for the compatibility statement here: https://github.com/docker-java/docker-java#docker-java

As you already found this is hard-coded in the AbstractDockerClientTest class. I will push some changes related to issue #388 soon that will change the tested API version.

@marcuslinke
Copy link
Copy Markdown
Contributor

After merging #392 I will take a look at your latest changes @vuminhkh.

@marcuslinke marcuslinke merged commit 477f4a1 into docker-java:master Dec 8, 2015
@marcuslinke
Copy link
Copy Markdown
Contributor

@vuminhkh Thanks for contributing!

@marcuslinke marcuslinke changed the title Implementations of Copy file to container command Implementation of copy archive to/from container commands Dec 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup