Skip to content

Commit 5bfb6c0

Browse files
authored
do not override pushed image's name (docker-java#1407)
1 parent 3d2c7a0 commit 5bfb6c0

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

docker-java-core/src/main/java/com/github/dockerjava/core/exec/PushImageCmdExec.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.fasterxml.jackson.core.type.TypeReference;
77
import com.github.dockerjava.api.async.ResultCallback;
88
import com.github.dockerjava.api.command.PushImageCmd;
9-
import com.github.dockerjava.api.model.AuthConfig;
109
import com.github.dockerjava.api.model.PushResponseItem;
1110
import com.github.dockerjava.core.DockerClientConfig;
1211
import com.github.dockerjava.core.InvocationBuilder;
@@ -22,17 +21,11 @@ public PushImageCmdExec(WebTarget baseResource, DockerClientConfig dockerClientC
2221
super(baseResource, dockerClientConfig);
2322
}
2423

25-
private String name(PushImageCmd command) {
26-
String name = command.getName();
27-
AuthConfig authConfig = command.getAuthConfig();
28-
return (name.contains("/") || authConfig == null) ? name : authConfig.getUsername();
29-
}
30-
3124
@Override
3225
protected Void execute0(PushImageCmd command, ResultCallback<PushResponseItem> resultCallback) {
33-
34-
WebTarget webResource = getBaseResource().path("/images/" + name(command) + "/push").queryParam("tag",
35-
command.getTag());
26+
WebTarget webResource = getBaseResource().path("/images/{imageName}/push")
27+
.resolveTemplate("imageName", command.getName())
28+
.queryParam("tag", command.getTag());
3629

3730
LOGGER.trace("POST: {}", webResource);
3831

docker-java/src/test/java/com/github/dockerjava/cmd/PushImageCmdIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void pushNonExistentImage() throws Exception {
7979
exception.expect(NotFoundException.class);
8080
}
8181

82-
dockerRule.getClient().pushImageCmd("local/" + UUID.randomUUID().toString().replace("-", ""))
82+
dockerRule.getClient().pushImageCmd(UUID.randomUUID().toString().replace("-", ""))
8383
.start()
8484
.awaitCompletion(30, TimeUnit.SECONDS); // exclude infinite await sleep
8585

0 commit comments

Comments
 (0)