Skip to content

Commit 7e50459

Browse files
committed
Merge pull request #128 from rtimush/unauthorized-pull
Allow unauthorized pullImageCmd
2 parents 2f9b736 + 4f969dc commit 7e50459

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/main/java/com/github/dockerjava/core/DockerClientImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public VersionCmd versionCmd() {
122122
@Override
123123
public PullImageCmd pullImageCmd(String repository) {
124124
return new PullImageCmdImpl(getDockerCmdExecFactory()
125-
.createPullImageCmdExec(), repository).withAuthConfig(dockerClientConfig.effectiveAuthConfig(repository));
125+
.createPullImageCmdExec(), dockerClientConfig.effectiveAuthConfig(repository), repository);
126126
}
127127

128128
@Override

src/main/java/com/github/dockerjava/core/command/AbstrAuthCfgDockerCmd.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
public abstract class AbstrAuthCfgDockerCmd<T extends DockerCmd<RES_T>, RES_T> extends
1616
AbstrDockerCmd<T, RES_T> {
1717

18+
public AbstrAuthCfgDockerCmd(DockerCmdExec<T, RES_T> execution, AuthConfig authConfig) {
19+
super(execution);
20+
withOptionalAuthConfig(authConfig);
21+
}
22+
1823
public AbstrAuthCfgDockerCmd(DockerCmdExec<T, RES_T> execution) {
1924
super(execution);
2025
}
@@ -25,9 +30,13 @@ public AuthConfig getAuthConfig() {
2530
return authConfig;
2631
}
2732

28-
@SuppressWarnings("unchecked")
2933
public T withAuthConfig(AuthConfig authConfig) {
3034
Preconditions.checkNotNull(authConfig, "authConfig was not specified");
35+
return withOptionalAuthConfig(authConfig);
36+
}
37+
38+
@SuppressWarnings("unchecked")
39+
private T withOptionalAuthConfig(AuthConfig authConfig) {
3140
this.authConfig = authConfig;
3241
return (T)this;
3342
}

src/main/java/com/github/dockerjava/core/command/PullImageCmdImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.dockerjava.core.command;
22

33
import com.github.dockerjava.api.command.PullImageCmd;
4+
import com.github.dockerjava.api.model.AuthConfig;
45
import com.google.common.base.Preconditions;
56

67
import java.io.InputStream;
@@ -14,8 +15,8 @@ public class PullImageCmdImpl extends AbstrAuthCfgDockerCmd<PullImageCmd, InputS
1415

1516
private String repository, tag, registry;
1617

17-
public PullImageCmdImpl(PullImageCmd.Exec exec, String repository) {
18-
super(exec);
18+
public PullImageCmdImpl(PullImageCmd.Exec exec, AuthConfig authConfig, String repository) {
19+
super(exec, authConfig);
1920
withRepository(repository);
2021
}
2122

0 commit comments

Comments
 (0)