X Tutup
Skip to content

Commit 4a6780b

Browse files
author
Marcus Linke
committed
Cleanup of model classes
1 parent 43027eb commit 4a6780b

File tree

11 files changed

+290
-469
lines changed

11 files changed

+290
-469
lines changed

src/main/java/com/github/dockerjava/client/Config.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
class Config {
1010
URI url;
1111
String version, username, password, email;
12+
Integer readTimeout;
13+
boolean enableLoggingFilter;
1214

1315
private Config() {
1416
}
@@ -51,6 +53,8 @@ static Config createConfig() throws DockerException {
5153
c.username = p.getProperty("docker.io.username");
5254
c.password = p.getProperty("docker.io.password");
5355
c.email = p.getProperty("docker.io.email");
56+
c.readTimeout = Integer.valueOf(p.getProperty("docker.io.readTimeout", "1000"));
57+
c.enableLoggingFilter = Boolean.valueOf(p.getProperty("docker.io.enableLoggingFilter", "true"));
5458

5559
return c;
5660
}

src/main/java/com/github/dockerjava/client/command/CreateContainerCmd.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.github.dockerjava.client.command;
22

3-
import java.util.HashMap;
4-
import java.util.Map;
5-
63
import javax.ws.rs.core.MediaType;
74
import javax.ws.rs.core.MultivaluedMap;
85

src/main/java/com/github/dockerjava/client/command/KillContainerCmd.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class KillContainerCmd extends AbstrDockerCmd<KillContainerCmd, Void> {
1717

1818
private static final Logger LOGGER = LoggerFactory.getLogger(KillContainerCmd.class);
1919

20-
private String containerId;
20+
private String containerId, signal;
2121

2222
public KillContainerCmd(String containerId) {
2323
withContainerId(containerId);
@@ -29,13 +29,23 @@ public KillContainerCmd withContainerId(String containerId) {
2929
return this;
3030
}
3131

32+
public KillContainerCmd withSignal(String signal) {
33+
Preconditions.checkNotNull(signal, "signal was not specified");
34+
this.signal = signal;
35+
return this;
36+
}
37+
3238
@Override
3339
public String toString() {
3440
return "kill " + containerId;
3541
}
3642

3743
protected Void impl() throws DockerException {
3844
WebResource webResource = baseResource.path(String.format("/containers/%s/kill", containerId));
45+
46+
if(signal != null) {
47+
webResource = webResource.queryParam("signal", signal);
48+
}
3949

4050
try {
4151
LOGGER.trace("POST: {}", webResource);

src/main/java/com/github/dockerjava/client/command/LogContainerCmd.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@
2626
* @param timestamps
2727
* - true or false, if true, print timestamps for every log line.
2828
* Defaults to false.
29+
* @param tail
30+
* - `all` or `<number>`, Output specified number of lines at the end of logs
2931
*/
3032
public class LogContainerCmd extends AbstrDockerCmd<LogContainerCmd, ClientResponse> {
3133

3234
private static final Logger LOGGER = LoggerFactory
3335
.getLogger(LogContainerCmd.class);
3436

3537
private String containerId;
38+
39+
private int tail = -1;
3640

3741
private boolean followStream, timestamps, stdout, stderr;
3842

@@ -77,6 +81,17 @@ public LogContainerCmd withStdErr(boolean stderr) {
7781
this.stderr = stderr;
7882
return this;
7983
}
84+
85+
public LogContainerCmd withTailAll() {
86+
this.tail = -1;
87+
return this;
88+
}
89+
90+
91+
public LogContainerCmd withTail(int tail) {
92+
this.tail = tail;
93+
return this;
94+
}
8095

8196
@Override
8297
public String toString() {
@@ -93,6 +108,7 @@ protected ClientResponse impl() throws DockerException {
93108
params.add("stdout", stdout ? "1" : "0");
94109
params.add("stderr", stderr ? "1" : "0");
95110
params.add("follow", followStream ? "1" : "0");
111+
params.add("tail", tail < 0 ? "all" : ""+ tail);
96112

97113
WebResource webResource = baseResource.path(
98114
String.format("/containers/%s/logs", containerId))

src/main/java/com/github/dockerjava/client/model/Container.java

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,26 @@
1313
@JsonIgnoreProperties(ignoreUnknown=true)
1414
public class Container {
1515

16-
@JsonProperty("Id")
17-
private String id;
16+
@JsonProperty("Command")
17+
private String command;
18+
19+
@JsonProperty("Created")
20+
private long created;
1821

19-
@JsonProperty("Command")
20-
private String command;
22+
@JsonProperty("Id")
23+
private String id;
2124

2225
@JsonProperty("Image")
2326
private String image;
2427

25-
@JsonProperty("Created")
26-
private long created;
27-
28-
@JsonProperty("Status")
29-
private String status;
28+
@JsonProperty("Names")
29+
private String[] names;
3030

3131
@JsonProperty("Ports")
3232
public Port[] ports;
3333

34-
@JsonProperty("SizeRw")
35-
private int size;
36-
37-
@JsonProperty("SizeRootFs")
38-
private int sizeRootFs;
39-
40-
@JsonProperty("Names")
41-
private String[] names;
34+
@JsonProperty("Status")
35+
private String status;
4236

4337
public String getId() {
4438
return id;
@@ -64,18 +58,6 @@ public Port[] getPorts() {
6458
return ports;
6559
}
6660

67-
public void setPorts(Port[] ports) {
68-
this.ports = ports;
69-
}
70-
71-
public int getSize() {
72-
return size;
73-
}
74-
75-
public int getSizeRootFs() {
76-
return sizeRootFs;
77-
}
78-
7961
public String[] getNames() {
8062
return names;
8163
}
@@ -90,8 +72,6 @@ public String toString() {
9072
", created=" + created +
9173
", status='" + status + '\'' +
9274
", ports=" + Arrays.toString(ports) +
93-
", size=" + size +
94-
", sizeRootFs=" + sizeRootFs +
9575
", names=" + Arrays.toString(names) +
9676
'}';
9777
}

0 commit comments

Comments
 (0)
X Tutup