Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e418e2e

Browse files
committed
push support
1 parent 7cbba4b commit e418e2e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/com/kpelykh/docker/client/DockerClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public void push(final String name) throws DockerException {
242242
}
243243
try {
244244
final String registryAuth = registryAuth();
245-
client.resource(restEndpointUrl + "/images/" + name + "/push")
245+
client.resource(restEndpointUrl + "/images/" + name(name) + "/push")
246246
.header("X-Registry-Auth", registryAuth)
247247
.accept(MediaType.APPLICATION_JSON)
248248
.post();
@@ -251,6 +251,10 @@ public void push(final String name) throws DockerException {
251251
}
252252
}
253253

254+
private String name(String name) {
255+
return name.contains("/") ? name : authConfig.getUsername();
256+
}
257+
254258
/**
255259
* Create an image by importing the given stream of a tar file.
256260
*

src/test/java/com/kpelykh/docker/client/test/DockerPushTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void beforeTest() throws Exception {
2323
@Test
2424
public void testPushLatest() throws Exception {
2525
setUpCredentials();
26-
docker.push("alexec/busybox");
26+
docker.push("busybox");
2727
assertThat(asString(docker.pull("alexec/busybox")), not(containsString("404")));
2828
}
2929

0 commit comments

Comments
 (0)