-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of POST /images/load endpoint #627
Conversation
About tar, maybe create it with text instructions in container and then copy from container (command already exists)? |
|
||
final Image image = findImageWithId(expectedImageId, dockerClient.listImagesCmd().exec()); | ||
|
||
assertNotNull(image, "Can't find expected image after loading from a tar archive"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use hamcrest matchers
in general lgtm beside comments |
Or even you can generate tar with apache.io tar, should be not so much lines of code! |
Please, give me more details. This image tarball should have a strict format. |
Sorry, right name of library https://commons.apache.org/proper/commons-compress/tar.html that would work for creating tar. Not sure about |
And one more idea, could you check how docker tests this case? https://github.com/docker/docker/search?utf8=%E2%9C%93&q=layer.tar |
|
||
@Test | ||
public void loadImageFromTar() throws Exception { | ||
final Path imageTarFile = Paths.get("src/test/resources/testLoadImageFromTar/image.tar"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use CurrentThread classloader to get input stream - as of on different os this path may be changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That load from relative path, it related to maven plugin that executes it from root of project. So classloaders unrelated. Ideally you should put test resources under class_name/test_name and then load from classloader this test resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give me an example of under class_name/test_name
rule? It looks like directories in src/test/resources/
violates this rule. Should I use src/test/resources/LoadImageCmdImplTest/loadImageFromTar/image.tar
? What if one resource is used by several classes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you can make public getter but place it in one place. The issue with placing just in resources that it will be like a trash can and after test deletions/refactorings they will be forgotten.
@leonsabr will search for examples bit later.
In order to get this tarball I manually did the following:
As I see, Docker guys have tarballs in repository:
As I understand you suggest to have text files in resources, then in runtime create a tarball according to format? It is tricky because tarball contains layer tarballs inside. So you need to create correct layer tarballs, then put them in the image tarball. By the way, I can do a smaller tarball, with one layer, a few kB. |
Or we can pick some their tarball.. |
So ok to have tarball in repo. But please place under corresponding class name |
What was changed in second commit:
I will squash commits for cleaner history later. |
@@ -90,6 +91,8 @@ | |||
|
|||
CreateImageCmd createImageCmd(@Nonnull String repository, @Nonnull InputStream imageStream); | |||
|
|||
LoadImageCmd loadImageCmd(@Nonnull InputStream imageStream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this feature appeared in docker API? Could you place javadoc with since
(example could be found through search) ?
LGTM, javadoc with API version would be welcome. |
It was tricky but I found the first reference of this endpoint in I squashed commits, so now all changes are in a single commit. |
@leonsabr thanks! it was enough to check latest 3-4 api versions and mark with latest known. I don't think that anybody using 1.8 :) |
@leonsabr 1.12 build fails with
Plus i found that it has verbose output #664 |
@@ -23,6 +23,11 @@ | |||
private static final Pattern VERSION_REGEX = Pattern.compile("v?(\\d+)\\.(\\d+)"); | |||
|
|||
/** | |||
* Online documentation is not available anymore. | |||
*/ | |||
public static final RemoteApiVersion VERSION_1_7 = RemoteApiVersion.create(1, 7); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sinde docker 1.7 or 1.7 API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found
This is an implementation of POST /images/load endpoint.
A few words about testing. I added a small tarball (20 kB) with a single image named "docker-java/load:1.0". Tests try to load this tarball into docker, check if expected image appears, and remove it in @AfterMethod. Test for
netty
implementation is the same as forjaxrs/jersey
implementation.This change is