X Tutup
Skip to content

Commit 9ef4f72

Browse files
author
Marcus Linke
committed
Merge branch 'andre1987-master'
2 parents b637b59 + 26cd47c commit 9ef4f72

18 files changed

+503
-76
lines changed

src/main/java/com/github/dockerjava/api/DockerClient.java

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,7 @@
22

33
import java.io.*;
44

5-
import com.github.dockerjava.api.command.AttachContainerCmd;
6-
import com.github.dockerjava.api.command.AuthCmd;
7-
import com.github.dockerjava.api.command.BuildImageCmd;
8-
import com.github.dockerjava.api.command.CommitCmd;
9-
import com.github.dockerjava.api.command.ContainerDiffCmd;
10-
import com.github.dockerjava.api.command.CopyFileFromContainerCmd;
11-
import com.github.dockerjava.api.command.CreateContainerCmd;
12-
import com.github.dockerjava.api.command.CreateImageCmd;
13-
import com.github.dockerjava.api.command.EventCallback;
14-
import com.github.dockerjava.api.command.EventsCmd;
15-
import com.github.dockerjava.api.command.InfoCmd;
16-
import com.github.dockerjava.api.command.InspectContainerCmd;
17-
import com.github.dockerjava.api.command.InspectImageCmd;
18-
import com.github.dockerjava.api.command.KillContainerCmd;
19-
import com.github.dockerjava.api.command.ListContainersCmd;
20-
import com.github.dockerjava.api.command.ListImagesCmd;
21-
import com.github.dockerjava.api.command.LogContainerCmd;
22-
import com.github.dockerjava.api.command.PauseContainerCmd;
23-
import com.github.dockerjava.api.command.PingCmd;
24-
import com.github.dockerjava.api.command.PullImageCmd;
25-
import com.github.dockerjava.api.command.PushImageCmd;
26-
import com.github.dockerjava.api.command.RemoveContainerCmd;
27-
import com.github.dockerjava.api.command.RemoveImageCmd;
28-
import com.github.dockerjava.api.command.RestartContainerCmd;
29-
import com.github.dockerjava.api.command.SearchImagesCmd;
30-
import com.github.dockerjava.api.command.StartContainerCmd;
31-
import com.github.dockerjava.api.command.StopContainerCmd;
32-
import com.github.dockerjava.api.command.TagImageCmd;
33-
import com.github.dockerjava.api.command.TopContainerCmd;
34-
import com.github.dockerjava.api.command.UnpauseContainerCmd;
35-
import com.github.dockerjava.api.command.VersionCmd;
36-
import com.github.dockerjava.api.command.WaitContainerCmd;
5+
import com.github.dockerjava.api.command.*;
376
import com.github.dockerjava.api.model.AuthConfig;
387

398
// https://godoc.org/github.com/fsouza/go-dockerclient
@@ -95,6 +64,8 @@ public CreateImageCmd createImageCmd(String repository,
9564
*/
9665
public StartContainerCmd startContainerCmd(String containerId);
9766

67+
public ExecCreateCmd execCreateCmd(String containerId);
68+
9869
public InspectContainerCmd inspectContainerCmd(String containerId);
9970

10071
public RemoveContainerCmd removeContainerCmd(String containerId);
@@ -103,6 +74,8 @@ public CreateImageCmd createImageCmd(String repository,
10374

10475
public AttachContainerCmd attachContainerCmd(String containerId);
10576

77+
public ExecStartCmd execStartCmd(String containerId);
78+
10679
public LogContainerCmd logContainerCmd(String containerId);
10780

10881
public CopyFileFromContainerCmd copyFileFromContainerCmd(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public interface AttachContainerCmd extends DockerCmd<InputStream>{
5151
public AttachContainerCmd withStdErr(boolean stderr);
5252

5353
public AttachContainerCmd withLogs(boolean logs);
54+
55+
public AttachContainerCmd withLogs();
5456

5557
/**
5658
* @throws NotFoundException No such container

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public interface DockerCmdExecFactory extends Closeable {
1515

1616
public PingCmd.Exec createPingCmdExec();
1717

18+
public ExecCreateCmd.Exec createExecCmdExec();
19+
1820
public VersionCmd.Exec createVersionCmdExec();
1921

2022
public PullImageCmd.Exec createPullImageCmdExec();
@@ -45,6 +47,8 @@ public interface DockerCmdExecFactory extends Closeable {
4547

4648
public AttachContainerCmd.Exec createAttachContainerCmdExec();
4749

50+
public ExecStartCmd.Exec createExecStartCmdExec();
51+
4852
public LogContainerCmd.Exec createLogContainerCmdExec();
4953

5054
public CopyFileFromContainerCmd.Exec createCopyFileFromContainerCmdExec();
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.github.dockerjava.api.command;
2+
3+
public interface ExecCreateCmd extends DockerCmd<ExecCreateCmdResponse> {
4+
5+
public String getContainerId();
6+
7+
public ExecCreateCmd withContainerId(String containerId);
8+
9+
public ExecCreateCmd withCmd(String... cmd);
10+
11+
public ExecCreateCmd withAttachStdin(boolean attachStdin);
12+
13+
public ExecCreateCmd withAttachStdin();
14+
15+
public boolean hasAttachStdinEnabled();
16+
17+
public ExecCreateCmd withAttachStdout(boolean attachStdout);
18+
19+
public ExecCreateCmd withAttachStdout();
20+
21+
public boolean hasAttachStdoutEnabled();
22+
23+
public ExecCreateCmd withAttachStderr(boolean attachStderr);
24+
25+
public ExecCreateCmd withAttachStderr();
26+
27+
public boolean hasAttachStderrEnabled();
28+
29+
public ExecCreateCmd withTty(boolean tty);
30+
31+
public ExecCreateCmd withTty();
32+
33+
public boolean hasTtyEnabled();
34+
35+
public static interface Exec extends DockerCmdExec<ExecCreateCmd, ExecCreateCmdResponse> {
36+
}
37+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
@JsonIgnoreProperties(ignoreUnknown = true)
7+
public class ExecCreateCmdResponse {
8+
9+
@JsonProperty("Id")
10+
private String id;
11+
12+
public String getId() {
13+
return id;
14+
}
15+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.github.dockerjava.api.NotFoundException;
4+
5+
import java.io.InputStream;
6+
7+
public interface ExecStartCmd extends DockerCmd<InputStream> {
8+
9+
public String getExecId();
10+
11+
public ExecStartCmd withExecId(String execId);
12+
13+
public boolean hasDetachEnabled();
14+
15+
public ExecStartCmd withDetach(boolean detach);
16+
17+
public ExecStartCmd withDetach();
18+
19+
public boolean hasTtyEnabled();
20+
21+
public ExecStartCmd withTty(boolean tty);
22+
23+
public ExecStartCmd withTty();
24+
25+
/**
26+
* @throws com.github.dockerjava.api.NotFoundException
27+
* No such exec instance
28+
*/
29+
@Override
30+
public InputStream exec() throws NotFoundException;
31+
32+
public static interface Exec extends
33+
DockerCmdExec<ExecStartCmd, InputStream> {
34+
}
35+
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ public InspectContainerCmd inspectContainerCmd(String containerId) {
193193
.createInspectContainerCmdExec(), containerId);
194194
}
195195

196+
@Override
197+
public ExecCreateCmd execCreateCmd(String containerId) {
198+
return new ExecCreateCmdImpl(getDockerCmdExecFactory().createExecCmdExec(), containerId);
199+
}
200+
196201
@Override
197202
public RemoveContainerCmd removeContainerCmd(String containerId) {
198203
return new RemoveContainerCmdImpl(getDockerCmdExecFactory()
@@ -211,6 +216,11 @@ public AttachContainerCmd attachContainerCmd(String containerId) {
211216
.createAttachContainerCmdExec(), containerId);
212217
}
213218

219+
@Override
220+
public ExecStartCmd execStartCmd(String containerId) {
221+
return new ExecStartCmdImpl(getDockerCmdExecFactory().createExecStartCmdExec(), containerId);
222+
}
223+
214224
@Override
215225
public LogContainerCmd logContainerCmd(String containerId) {
216226
return new LogContainerCmdImpl(getDockerCmdExecFactory()

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ public AttachContainerCmd withLogs(boolean logs) {
116116
return this;
117117
}
118118

119+
@Override
120+
public AttachContainerCmd withLogs() {
121+
return withLogs(true);
122+
}
123+
119124
/**
120125
* @throws NotFoundException No such container
121126
*/
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
package com.github.dockerjava.core.command;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.github.dockerjava.api.NotFoundException;
5+
import com.github.dockerjava.api.command.ExecCreateCmd;
6+
import com.github.dockerjava.api.command.ExecCreateCmdResponse;
7+
import com.google.common.base.Preconditions;
8+
9+
public class ExecCreateCmdImpl extends AbstrDockerCmd<ExecCreateCmd, ExecCreateCmdResponse> implements ExecCreateCmd {
10+
11+
private String containerId;
12+
13+
@JsonProperty("AttachStdin")
14+
private boolean attachStdin;
15+
16+
@JsonProperty("AttachStdout")
17+
private boolean attachStdout;
18+
19+
@JsonProperty("AttachStderr")
20+
private boolean attachStderr;
21+
22+
@JsonProperty("Tty")
23+
private boolean tty;
24+
25+
@JsonProperty("Cmd")
26+
private String[] cmd;
27+
28+
public ExecCreateCmdImpl(ExecCreateCmd.Exec exec, String containerId) {
29+
super(exec);
30+
withContainerId(containerId);
31+
}
32+
33+
public ExecCreateCmd withContainerId(String containerId) {
34+
Preconditions.checkNotNull(containerId, "containerId was not specified");
35+
this.containerId = containerId;
36+
return this;
37+
}
38+
39+
public ExecCreateCmd withAttachStdin(boolean attachStdin) {
40+
this.attachStdin = attachStdin;
41+
return this;
42+
}
43+
44+
public ExecCreateCmd withAttachStdin() {
45+
return withAttachStdin(true);
46+
}
47+
48+
public ExecCreateCmd withAttachStdout(boolean attachStdout) {
49+
this.attachStdout = attachStdout;
50+
return this;
51+
}
52+
53+
public ExecCreateCmd withAttachStdout() {
54+
return withAttachStdout(true);
55+
}
56+
57+
public ExecCreateCmd withAttachStderr(boolean attachStderr) {
58+
this.attachStderr = attachStderr;
59+
return this;
60+
}
61+
62+
public ExecCreateCmd withAttachStderr() {
63+
return withAttachStderr(true);
64+
}
65+
66+
public ExecCreateCmd withTty(boolean tty) {
67+
this.tty = tty;
68+
return this;
69+
}
70+
71+
public ExecCreateCmd withTty() {
72+
return withTty(true);
73+
}
74+
75+
public ExecCreateCmd withCmd(String... cmd) {
76+
this.cmd = cmd;
77+
return this;
78+
}
79+
80+
@Override
81+
public String getContainerId() {
82+
return containerId;
83+
}
84+
85+
@Override
86+
public boolean hasAttachStdinEnabled() {
87+
return attachStdin;
88+
}
89+
90+
@Override
91+
public boolean hasAttachStdoutEnabled() {
92+
return attachStdout;
93+
}
94+
95+
@Override
96+
public boolean hasAttachStderrEnabled() {
97+
return attachStderr;
98+
}
99+
100+
@Override
101+
public boolean hasTtyEnabled() {
102+
return tty;
103+
}
104+
105+
/**
106+
* @throws NotFoundException No such container
107+
*/
108+
@Override
109+
public ExecCreateCmdResponse exec() throws NotFoundException {
110+
return super.exec();
111+
}
112+
113+
114+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package com.github.dockerjava.core.command;
2+
3+
import com.github.dockerjava.api.NotFoundException;
4+
import com.github.dockerjava.api.command.ExecStartCmd;
5+
import com.google.common.base.Preconditions;
6+
7+
import java.io.InputStream;
8+
9+
public class ExecStartCmdImpl extends AbstrDockerCmd<ExecStartCmd, InputStream> implements ExecStartCmd {
10+
11+
private String execId;
12+
13+
private boolean detach, tty;
14+
15+
public ExecStartCmdImpl(ExecStartCmd.Exec exec, String containerId) {
16+
super(exec);
17+
Preconditions.checkNotNull(containerId, "containerId was not specified");
18+
this.execId = containerId;
19+
}
20+
21+
@Override
22+
public String getExecId() {
23+
return execId;
24+
}
25+
26+
@Override
27+
public ExecStartCmd withExecId(String execId) {
28+
Preconditions.checkNotNull(execId, "execId was not specified");
29+
this.execId = execId;
30+
return this;
31+
}
32+
33+
@Override
34+
public boolean hasDetachEnabled() {
35+
return detach;
36+
}
37+
38+
@Override
39+
public boolean hasTtyEnabled() {
40+
return tty;
41+
}
42+
43+
@Override
44+
public ExecStartCmd withDetach(boolean detach) {
45+
this.detach = detach;
46+
return this;
47+
}
48+
49+
@Override
50+
public ExecStartCmd withTty(boolean tty) {
51+
this.tty = tty;
52+
return null;
53+
}
54+
55+
@Override
56+
public ExecStartCmd withDetach() {
57+
return withDetach(true);
58+
}
59+
60+
@Override
61+
public ExecStartCmd withTty() {
62+
return withTty(true);
63+
}
64+
65+
/**
66+
* @throws com.github.dockerjava.api.NotFoundException No such exec instance
67+
*/
68+
@Override
69+
public InputStream exec() throws NotFoundException {
70+
return super.exec();
71+
}
72+
73+
}

0 commit comments

Comments
 (0)
X Tutup