Skip to content

Commit 47cefcd

Browse files
committed
Merge pull request #186 from docker-java/issue-184
Added withPull method to BuilImageCmd
2 parents e08695b + 3214f5f commit 47cefcd

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/main/java/com/github/dockerjava/api/command/BuildImageCmd.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ public interface BuildImageCmd extends DockerCmd<BuildImageCmd.Response>{
2525
public boolean hasNoCacheEnabled();
2626

2727
public boolean hasRemoveEnabled();
28-
28+
2929
public boolean isQuiet();
30+
31+
public boolean hasPullEnabled();
3032

3133
public String getPathToDockerfile();
3234

@@ -50,6 +52,10 @@ public interface BuildImageCmd extends DockerCmd<BuildImageCmd.Response>{
5052

5153
public BuildImageCmd withQuiet(boolean quiet);
5254

55+
public BuildImageCmd withPull();
56+
57+
public BuildImageCmd withPull(boolean pull);
58+
5359
public BuildImageCmd withBuildAuthConfigs(AuthConfigurations authConfig);
5460

5561
public static interface Exec extends DockerCmdExec<BuildImageCmd, BuildImageCmd.Response> {

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class BuildImageCmdImpl extends AbstrDockerCmd<BuildImageCmd, BuildImageC
2424
private boolean noCache;
2525
private boolean remove = true;
2626
private boolean quiet;
27+
private boolean pull;
28+
2729
private AuthConfigurations buildAuthConfigs;
2830
private File dockerFile;
2931
private File baseDirectory;
@@ -115,6 +117,11 @@ public boolean hasRemoveEnabled() {
115117
public boolean isQuiet() {
116118
return quiet;
117119
}
120+
121+
@Override
122+
public boolean hasPullEnabled() {
123+
return pull;
124+
}
118125

119126
@Override
120127
public String getPathToDockerfile() {
@@ -165,6 +172,17 @@ public BuildImageCmdImpl withQuiet(boolean quiet) {
165172
this.quiet = quiet;
166173
return this;
167174
}
175+
176+
@Override
177+
public BuildImageCmdImpl withPull() {
178+
return withPull(true);
179+
}
180+
181+
@Override
182+
public BuildImageCmdImpl withPull(boolean pull) {
183+
this.pull = pull;
184+
return this;
185+
}
168186

169187
@Override
170188
public BuildImageCmd withBuildAuthConfigs(AuthConfigurations authConfigs) {

src/main/java/com/github/dockerjava/jaxrs/BuildImageCmdExec.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ protected ResponseImpl execute(BuildImageCmd command) {
5252
if (command.isQuiet()) {
5353
webResource = webResource.queryParam("q", "true");
5454
}
55+
if (command.hasPullEnabled()) {
56+
webResource = webResource.queryParam("pull", "true");
57+
}
5558
if (dockerFilePath != null && !"Dockerfile".equals(dockerFilePath)) {
5659
webResource = webResource.queryParam("dockerfile", dockerFilePath);
5760
}

0 commit comments

Comments
 (0)