Skip to content

Conversation

@orzeh
Copy link
Contributor

@orzeh orzeh commented Nov 15, 2016

Several tags for image can be defined by subsequent calling withTag() method of BuildImageCmd.

@marcuslinke please check my modifications of Netty WebTarget class to support several query parameters with the same name as this class is widely used.


This change is Reviewable

Several tags for image can be defined by calling multiple time withTag() method of BuildImageCmd.
In Netty implementation, the WebTarget class is modified to support several query parameteres with the same name. 
Fix #720
private InputStream tarInputStream;

private String tag;
private Set<String> tags;
Copy link
Member

Choose a reason for hiding this comment

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

NO don't remove existing fields either you will break all < 1.21 users.

Copy link
Contributor Author

@orzeh orzeh Nov 15, 2016

Choose a reason for hiding this comment

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

This is a private filed - to preserve backward compatibility I've left getTag() method.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, first of all it Cmd in cmd we can break compatibility, but better do .Y increment in version then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this is a breaking change - previously written code will still work with all versions of Docker engine (unless you already called withTag() multiple times).

This change add some features so feel free to release it with incremented .Y in version.

if (this.tags == null) {
this.tags = new HashSet<>(4);
}
this.tags.add(tag);
Copy link
Member

Choose a reason for hiding this comment

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

you can't be sure what target API is used to know what to put. Add version check to get conditional and default to latest behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KostyaSha is such version check already implemented somewhere in the code base or I have to write one?

Copy link
Member

Choose a reason for hiding this comment

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

Check the place where Auth headers are added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was unable to find it. However, IMO there is no need to do version check. In recently added labels support we do not check Docker engine version either. Client will use this features when targeting newer version of Docker.

@codecov-io
Copy link

codecov-io commented Nov 19, 2016

Codecov Report

Merging #739 into master will increase coverage by 0.14%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #739      +/-   ##
==========================================
+ Coverage   71.61%   71.75%   +0.14%     
==========================================
  Files         306      306              
  Lines        6584     6597      +13     
  Branches      483      488       +5     
==========================================
+ Hits         4715     4734      +19     
+ Misses       1582     1577       -5     
+ Partials      287      286       -1
Impacted Files Coverage Δ
...in/java/com/github/dockerjava/netty/WebTarget.java 74.46% <100%> (+2.37%) ⬆️
...hub/dockerjava/core/command/BuildImageCmdImpl.java 59.57% <100%> (+1.33%) ⬆️
...ithub/dockerjava/netty/exec/BuildImageCmdExec.java 54.9% <33.33%> (-0.21%) ⬇️
...com/github/dockerjava/jaxrs/BuildImageCmdExec.java 56.36% <80%> (+1.46%) ⬆️
...ava/netty/handler/FramedResponseStreamHandler.java 89.65% <0%> (+3.44%) ⬆️
...va/org/apache/http/impl/io/ChunkedInputStream.java 61.16% <0%> (+5.82%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f9fdc39...8e1f392. Read the comment docs.

@orzeh
Copy link
Contributor Author

orzeh commented Feb 12, 2017

@KostyaSha Is there anything else I should do before it can be merged?

* @deprecated since docker API version 1.21 there can be multiple tags
* specified so use {@link #getTags()}
*/
@Deprecated()
Copy link
Member

Choose a reason for hiding this comment

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

Just @Deprecated

return null;
}
// return first tag to be backward compatible
return tags.iterator().next();
Copy link
Member

Choose a reason for hiding this comment

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

So maybe keep both fields and pick List<> and if it null or empty return getTag()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KostyaSha ok, but then we end up with withTag(String tag) and new method withTags(Set<String> tags) - I don't think this is more elegant solution. But you decide.

Copy link
Member

Choose a reason for hiding this comment

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

if i right understand witTag(String) is already existing and we can Deprecate it and remove in future and add new Set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

File baseDir = fileFromBuildTestResource("labels");

String imageId = dockerClient.buildImageCmd(baseDir).withNoCache(true)
.withTag("docker-java-test:tag1").withTag("docker-java-test:tag2")
Copy link
Member

Choose a reason for hiding this comment

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

imho that looks not obvious. If user wants only one tag it should call .withTag if multiple then .withTags(Set<String>) Maybe keep getTag() and add getTags() and prefer getTags with fallback to getTag()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I'll do it this way 😄

LOG.info("Image Inspect: {}", inspectImageResponse.toString());

assertThat(inspectImageResponse.getRepoTags().size(), equalTo(2));
assertThat(inspectImageResponse.getRepoTags().contains("docker-java-test:tag1"), equalTo(true));
Copy link
Member

@KostyaSha KostyaSha Mar 28, 2017

Choose a reason for hiding this comment

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

if inspectImageResponse.getRepoTags() it return List or collection then you need search for hamcrest matcher (probably see example at com/github/dockerjava/core/command/CreateContainerCmdImplTest.java:165 or com/github/dockerjava/core/command/CreateContainerCmdImplTest.java:191 remember that some matchers are strict ordered and docker may return in different order items (even depends on java collection types afair))

This was referenced Apr 23, 2017
@KostyaSha KostyaSha added this to the 3.0.10 milestone May 5, 2017
@KostyaSha KostyaSha closed this May 5, 2017
@MarkRx
Copy link

MarkRx commented May 5, 2017

Was this supposed to be merged instead of closed?

Looks like it was moved to #835

KostyaSha added a commit that referenced this pull request May 5, 2017
Reworked PR #739 (multiple tags)
panuse pushed a commit to TuKangTech/docker-java that referenced this pull request Aug 20, 2017
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.

4 participants