Skip to content

Commit 49304d8

Browse files
committed
Merge pull request #488 from KostyaSha/1.22-cleanup
1.22 cleanup
2 parents b5c7f44 + 241257c commit 49304d8

File tree

66 files changed

+4373
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4373
-266
lines changed

docs/devel.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Code Design
2+
* Model is based on Objects and not primitives that allows nullify requests and have null values for data
3+
that wasn't provided by docker daemon.
4+
* For null safeness findbugs annotations are used.
5+
** Every method that may return `null` (and we are unsure in any fields as docker daemon may change something)
6+
should be annotated with `@CheckForNull` return qualifier from `javax.annotation` package.
7+
** Methods that can't return `null` must be annotated with `@Nonnull`.
8+
** The same for Arguments.
9+
** `@Nullable` must be used only for changing inherited (other typed) qualifier.
10+
* Setters in builder style must be prefixed with `withXX`.
11+
* All classes should provide `toString()` `equals()` and `hashCode()` defined methods.
12+
* Javadocs
13+
** Provide full information on field:
14+
*** For models define API version with `@since {@link RemoteApiVersion#VERSION_1_X}`.
15+
** getters/setters should refernce to field `@see #$field`.
16+
17+
### Coding style
18+
* TBD, some initial styling already enforced with checkstyle.
19+
IDEA/checkstyle file analogues will be provided soon.
20+
21+
### Testing
22+
* Unit tests for serder (serialization-deserialization).
23+
* Integration tests for commands.
24+
* If model object has builders, then fill it with data and compare by `equals()` with expected response
25+
from docker daemon. If failed, then some fields mappings are wrong.

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
<maven-jar-plugin.version>2.2</maven-jar-plugin.version>
7373
<maven-compiler-plugin.version>2.3.1</maven-compiler-plugin.version>
7474
<maven-release-plugin.version>2.3.1</maven-release-plugin.version>
75-
<maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
76-
<maven-failsafe-plugin.version>2.17</maven-failsafe-plugin.version>
75+
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
76+
<maven-failsafe-plugin.version>2.19.1</maven-failsafe-plugin.version>
7777
<maven-antrun-plugin.version>1.7</maven-antrun-plugin.version>
7878
</properties>
7979

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import com.github.dockerjava.api.command.TagImageCmd;
5454
import com.github.dockerjava.api.command.TopContainerCmd;
5555
import com.github.dockerjava.api.command.UnpauseContainerCmd;
56+
import com.github.dockerjava.api.command.UpdateContainerCmd;
5657
import com.github.dockerjava.api.command.VersionCmd;
5758
import com.github.dockerjava.api.command.WaitContainerCmd;
5859
import com.github.dockerjava.api.exception.DockerException;
@@ -175,6 +176,15 @@ public interface DockerClient extends Closeable {
175176

176177
public KillContainerCmd killContainerCmd(@Nonnull String containerId);
177178

179+
/**
180+
* Update container settings
181+
*
182+
* @param containerId id of the container
183+
* @return command
184+
* @since {@link RemoteApiVersion#VERSION_1_22}
185+
*/
186+
public UpdateContainerCmd updateContainerCmd(@Nonnull String containerId);
187+
178188
public RestartContainerCmd restartContainerCmd(@Nonnull String containerId);
179189

180190
public CommitCmd commitCmd(@Nonnull String containerId);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public interface CreateContainerCmd extends SyncDockerCmd<CreateContainerRespons
8080
@CheckForNull
8181
public ExposedPort[] getExposedPorts();
8282

83+
@CheckForNull
84+
public String getStopSignal();
85+
8386
@CheckForNull
8487
public String[] getExtraHosts();
8588

@@ -280,6 +283,8 @@ public interface CreateContainerCmd extends SyncDockerCmd<CreateContainerRespons
280283

281284
public CreateContainerCmd withExposedPorts(ExposedPort... exposedPorts);
282285

286+
public CreateContainerCmd withStopSignal(String stopSignal);
287+
283288
public CreateContainerCmd withExposedPorts(List<ExposedPort> exposedPorts);
284289

285290
/**

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

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

7070
public KillContainerCmd.Exec createKillContainerCmdExec();
7171

72+
UpdateContainerCmd.Exec createUpdateContainerCmdExec();
73+
7274
public RestartContainerCmd.Exec createRestartContainerCmdExec();
7375

7476
public CommitCmd.Exec createCommitCmdExec();

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,5 +462,68 @@ public String getMode() {
462462
public Boolean getRW() {
463463
return rw;
464464
}
465+
466+
/**
467+
* @see #destination
468+
*/
469+
public Mount withDestination(Volume destination) {
470+
this.destination = destination;
471+
return this;
472+
}
473+
474+
/**
475+
* @see #driver
476+
*/
477+
public Mount withDriver(String driver) {
478+
this.driver = driver;
479+
return this;
480+
}
481+
482+
/**
483+
* @see #mode
484+
*/
485+
public Mount withMode(String mode) {
486+
this.mode = mode;
487+
return this;
488+
}
489+
490+
/**
491+
* @see #name
492+
*/
493+
public Mount withName(String name) {
494+
this.name = name;
495+
return this;
496+
}
497+
498+
/**
499+
* @see #rw
500+
*/
501+
public Mount withRw(Boolean rw) {
502+
this.rw = rw;
503+
return this;
504+
}
505+
506+
/**
507+
* @see #source
508+
*/
509+
public Mount withSource(String source) {
510+
this.source = source;
511+
return this;
512+
}
513+
514+
@Override
515+
public String toString() {
516+
return ToStringBuilder.reflectionToString(this);
517+
}
518+
519+
@Override
520+
public boolean equals(Object o) {
521+
return EqualsBuilder.reflectionEquals(this, o);
522+
}
523+
524+
@Override
525+
public int hashCode() {
526+
return HashCodeBuilder.reflectionHashCode(this);
527+
}
465528
}
466529
}

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import com.github.dockerjava.api.model.NetworkSettings;
1010
import com.github.dockerjava.core.RemoteApiVersion;
1111

12+
import javax.annotation.CheckForNull;
13+
1214
@JsonIgnoreProperties(ignoreUnknown = true)
1315
public class InspectExecResponse {
1416
@JsonProperty("ID")
@@ -26,15 +28,37 @@ public class InspectExecResponse {
2628
@JsonProperty("Running")
2729
private Boolean running;
2830

31+
/**
32+
* @since {@link RemoteApiVersion#VERSION_1_22}
33+
*/
34+
@JsonProperty("CanRemove")
35+
private Boolean canRemove;
36+
2937
@JsonProperty("ExitCode")
3038
private Integer exitCode;
3139

3240
@JsonProperty("ProcessConfig")
3341
private ProcessConfig processConfig;
3442

43+
/**
44+
* @deprecated @since {@link RemoteApiVersion#VERSION_1_22}
45+
*/
46+
@Deprecated
3547
@JsonProperty("Container")
3648
private Container container;
3749

50+
/**
51+
* @since {@link RemoteApiVersion#VERSION_1_22}
52+
*/
53+
@JsonProperty("ContainerID")
54+
private String containerID;
55+
56+
/**
57+
* @since {@link RemoteApiVersion#VERSION_1_22}
58+
*/
59+
@JsonProperty("DetachKeys")
60+
private String detachKeys;
61+
3862
public String getId() {
3963
return id;
4064
}
@@ -63,10 +87,38 @@ public ProcessConfig getProcessConfig() {
6387
return processConfig;
6488
}
6589

90+
/**
91+
* @see #container
92+
*/
93+
@Deprecated
6694
public Container getContainer() {
6795
return container;
6896
}
6997

98+
/**
99+
* @see #canRemove
100+
*/
101+
@CheckForNull
102+
public Boolean getCanRemove() {
103+
return canRemove;
104+
}
105+
106+
/**
107+
* @see #containerID
108+
*/
109+
@CheckForNull
110+
public String getContainerID() {
111+
return containerID;
112+
}
113+
114+
/**
115+
* @see #detachKeys
116+
*/
117+
@CheckForNull
118+
public String getDetachKeys() {
119+
return detachKeys;
120+
}
121+
70122
@Override
71123
public String toString() {
72124
return ToStringBuilder.reflectionToString(this);
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.github.dockerjava.api.model.UpdateContainerResponse;
4+
import com.github.dockerjava.core.RemoteApiVersion;
5+
6+
import javax.annotation.CheckForNull;
7+
import javax.annotation.Nonnull;
8+
9+
/**
10+
* @author Kanstantsin Shautsou
11+
* @since {@link RemoteApiVersion#VERSION_1_22}
12+
*/
13+
public interface UpdateContainerCmd extends SyncDockerCmd<UpdateContainerResponse> {
14+
@CheckForNull
15+
String getContainerId();
16+
17+
@CheckForNull
18+
public Integer getBlkioWeight();
19+
20+
public UpdateContainerCmd withBlkioWeight(Integer blkioWeight);
21+
22+
public UpdateContainerCmd withContainerId(@Nonnull String containerId);
23+
24+
@CheckForNull
25+
public Integer getCpuPeriod();
26+
27+
public UpdateContainerCmd withCpuPeriod(Integer cpuPeriod);
28+
29+
@CheckForNull
30+
public Integer getCpuQuota();
31+
32+
public UpdateContainerCmd withCpuQuota(Integer cpuQuota);
33+
34+
@CheckForNull
35+
public String getCpusetCpus();
36+
37+
public UpdateContainerCmd withCpusetCpus(String cpusetCpus);
38+
39+
@CheckForNull
40+
public String getCpusetMems();
41+
42+
public UpdateContainerCmd withCpusetMems(String cpusetMems);
43+
44+
@CheckForNull
45+
public Integer getCpuShares();
46+
47+
public UpdateContainerCmd withCpuShares(Integer cpuShares);
48+
49+
@CheckForNull
50+
public Long getKernelMemory();
51+
52+
public UpdateContainerCmd withKernelMemory(Long kernelMemory);
53+
54+
@CheckForNull
55+
public Long getMemory();
56+
57+
public UpdateContainerCmd withMemory(Long memory);
58+
59+
@CheckForNull
60+
public Long getMemoryReservation();
61+
62+
public UpdateContainerCmd withMemoryReservation(Long memoryReservation);
63+
64+
@CheckForNull
65+
Long getMemorySwap();
66+
67+
UpdateContainerCmd withMemorySwap(Long memorySwap);
68+
69+
interface Exec extends DockerCmdSyncExec<UpdateContainerCmd, UpdateContainerResponse> {
70+
}
71+
}

src/main/java/com/github/dockerjava/api/model/AuthConfig.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import com.fasterxml.jackson.annotation.JsonInclude.Include;
88
import com.fasterxml.jackson.annotation.JsonProperty;
99

10+
import javax.annotation.CheckForNull;
11+
1012
@JsonInclude(Include.NON_NULL)
1113
public class AuthConfig {
1214

@@ -32,6 +34,12 @@ public class AuthConfig {
3234
@JsonProperty("auth")
3335
private String auth;
3436

37+
/**
38+
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_22}
39+
*/
40+
@JsonProperty("registrytoken")
41+
private String registrytoken;
42+
3543
public String getUsername() {
3644
return username;
3745
}
@@ -77,6 +85,22 @@ public AuthConfig withAuth(String auth) {
7785
return this;
7886
}
7987

88+
/**
89+
* @see #registrytoken
90+
*/
91+
@CheckForNull
92+
public String getRegistrytoken() {
93+
return registrytoken;
94+
}
95+
96+
/**
97+
* @see #registrytoken
98+
*/
99+
public AuthConfig withRegistrytoken(String registrytoken) {
100+
this.registrytoken = registrytoken;
101+
return this;
102+
}
103+
80104
@Override
81105
public String toString() {
82106
return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);

0 commit comments

Comments
 (0)