Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b97fc4d
[WIP] Syncing 1.22
KostyaSha Feb 17, 2016
8c93adf
Update Info
KostyaSha Feb 17, 2016
93b9dc8
Update info
KostyaSha Feb 17, 2016
2ad06b1
Update /version
KostyaSha Feb 17, 2016
074883a
Update create request
KostyaSha Feb 17, 2016
d25eda0
InfoTest, ContainerTest, fix getter.
KostyaSha Feb 19, 2016
dc5e6c6
Extract classes
KostyaSha Feb 19, 2016
d9a30cb
Document code rules.
KostyaSha Feb 19, 2016
18a6307
Remove package prefix for already imported class.
KostyaSha Feb 20, 2016
c18177e
HostConfig.class: setXX() -> withXX()
KostyaSha Feb 20, 2016
cf39893
Info.class
KostyaSha Feb 20, 2016
f69c056
Extract nested class from Info.class
KostyaSha Feb 20, 2016
25018fc
Restore getter name.
KostyaSha Feb 20, 2016
57a2807
Test case Info and fix.
KostyaSha Feb 21, 2016
5ca5e63
Switch to reflection methods.
KostyaSha Feb 21, 2016
3087078
Version.class to use reflection.
KostyaSha Feb 21, 2016
aaa5e4b
Clean-up imports.
KostyaSha Feb 21, 2016
a39d5fc
Version.class serder test
KostyaSha Feb 21, 2016
642c94f
AuthConfig.class add serder tests.
KostyaSha Feb 21, 2016
7a8513d
ContainerPort.class to reflection.
KostyaSha Feb 21, 2016
051a0fa
HostConfig.class to refleciton.
KostyaSha Feb 21, 2016
5e70093
Test for CreateContainer with stopSignal
KostyaSha Feb 22, 2016
35865ba
Implement UpdateContainerCmd with tests
KostyaSha Feb 22, 2016
6482e77
Update devel doc.
KostyaSha Feb 22, 2016
97baacd
Fix junit errors?
KostyaSha Feb 22, 2016
284d145
Update maven surefire
KostyaSha Feb 26, 2016
2f3aa8b
Fix and update test.
KostyaSha Feb 26, 2016
71d5ecb
Fix jaxrs test
KostyaSha Feb 26, 2016
7631991
Add helper for api version extraction
KostyaSha Feb 26, 2016
0e9ba93
Deprecate container field
KostyaSha Feb 26, 2016
3e79e88
Do test conditional.
KostyaSha Feb 26, 2016
5336f8c
Fix sync test to be async.
KostyaSha Feb 26, 2016
2ec5fb3
Fix NegativeArraySizeException in awaitCompletion()
KostyaSha Feb 29, 2016
01f1468
Cleanup test code after fix.
KostyaSha Feb 29, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/devel.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
### Code Design
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcuslinke review this doc?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KostyaSha LGTM

* Model is based on Objects and not primitives that allows nullify requests and have null values for data
that wasn't provided by docker daemon.
* For null safeness findbugs annotations are used.
** Every method that may return `null` (and we are unsure in any fields as docker daemon may change something)
should be annotated with `@CheckForNull` return qualifier from `javax.annotation` package.
** Methods that can't return `null` must be annotated with `@Nonnull`.
** The same for Arguments.
** `@Nullable` must be used only for changing inherited (other typed) qualifier.
* Setters in builder style must be prefixed with `withXX`.
* All classes should provide `toString()` `equals()` and `hashCode()` defined methods.
* Javadocs
** Provide full information on field:
*** For models define API version with `@since {@link RemoteApiVersion#VERSION_1_X}`.
** getters/setters should refernce to field `@see #$field`.

### Coding style
* TBD, some initial styling already enforced with checkstyle.
IDEA/checkstyle file analogues will be provided soon.

### Testing
* Unit tests for serder (serialization-deserialization).
* Integration tests for commands.
* If model object has builders, then fill it with data and compare by `equals()` with expected response
from docker daemon. If failed, then some fields mappings are wrong.
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
<maven-jar-plugin.version>2.2</maven-jar-plugin.version>
<maven-compiler-plugin.version>2.3.1</maven-compiler-plugin.version>
<maven-release-plugin.version>2.3.1</maven-release-plugin.version>
<maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>2.17</maven-failsafe-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>2.19.1</maven-failsafe-plugin.version>
<maven-antrun-plugin.version>1.7</maven-antrun-plugin.version>
</properties>

Expand Down Expand Up @@ -124,6 +124,11 @@
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.commons</groupId>-->
<!--<artifactId>commons-collections4</artifactId>-->
<!--<version>4.1</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/github/dockerjava/api/DockerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import com.github.dockerjava.api.command.TagImageCmd;
import com.github.dockerjava.api.command.TopContainerCmd;
import com.github.dockerjava.api.command.UnpauseContainerCmd;
import com.github.dockerjava.api.command.UpdateContainerCmd;
import com.github.dockerjava.api.command.VersionCmd;
import com.github.dockerjava.api.command.WaitContainerCmd;
import com.github.dockerjava.api.exception.DockerException;
Expand Down Expand Up @@ -175,6 +176,15 @@ public interface DockerClient extends Closeable {

public KillContainerCmd killContainerCmd(@Nonnull String containerId);

/**
* Update container settings
*
* @param containerId id of the container
* @return command
* @since {@link RemoteApiVersion#VERSION_1_22}
*/
public UpdateContainerCmd updateContainerCmd(@Nonnull String containerId);

public RestartContainerCmd restartContainerCmd(@Nonnull String containerId);

public CommitCmd commitCmd(@Nonnull String containerId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public interface CreateContainerCmd extends SyncDockerCmd<CreateContainerRespons
@CheckForNull
public ExposedPort[] getExposedPorts();

@CheckForNull
public String getStopSignal();

@CheckForNull
public String[] getExtraHosts();

Expand Down Expand Up @@ -280,6 +283,8 @@ public interface CreateContainerCmd extends SyncDockerCmd<CreateContainerRespons

public CreateContainerCmd withExposedPorts(ExposedPort... exposedPorts);

public CreateContainerCmd withStopSignal(String stopSignal);

public CreateContainerCmd withExposedPorts(List<ExposedPort> exposedPorts);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public interface DockerCmdExecFactory extends Closeable {

public KillContainerCmd.Exec createKillContainerCmdExec();

UpdateContainerCmd.Exec createUpdateContainerCmdExec();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use public keyword or remove other public keywords.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in next PR will do and it TODO enable checkstyle.


public RestartContainerCmd.Exec createRestartContainerCmdExec();

public CommitCmd.Exec createCommitCmdExec();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.github.dockerjava.api.model.NetworkSettings;
import com.github.dockerjava.core.RemoteApiVersion;

import javax.annotation.CheckForNull;

@JsonIgnoreProperties(ignoreUnknown = true)
public class InspectExecResponse {
@JsonProperty("ID")
Expand All @@ -26,15 +28,37 @@ public class InspectExecResponse {
@JsonProperty("Running")
private Boolean running;

/**
* @since {@link RemoteApiVersion#VERSION_1_22}
*/
@JsonProperty("CanRemove")
private Boolean canRemove;

@JsonProperty("ExitCode")
private Integer exitCode;

@JsonProperty("ProcessConfig")
private ProcessConfig processConfig;

/**
* @deprecated @since {@link RemoteApiVersion#VERSION_1_22}
*/
@Deprecated
@JsonProperty("Container")
private Container container;

/**
* @since {@link RemoteApiVersion#VERSION_1_22}
*/
@JsonProperty("ContainerID")
private String containerID;

/**
* @since {@link RemoteApiVersion#VERSION_1_22}
*/
@JsonProperty("DetachKeys")
private String detachKeys;

public String getId() {
return id;
}
Expand Down Expand Up @@ -63,10 +87,38 @@ public ProcessConfig getProcessConfig() {
return processConfig;
}

/**
* @see #container
*/
@Deprecated
public Container getContainer() {
return container;
}

/**
* @see #canRemove
*/
@CheckForNull
public Boolean getCanRemove() {
return canRemove;
}

/**
* @see #containerID
*/
@CheckForNull
public String getContainerID() {
return containerID;
}

/**
* @see #detachKeys
*/
@CheckForNull
public String getDetachKeys() {
return detachKeys;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.github.dockerjava.api.command;

import com.github.dockerjava.api.model.UpdateContainerResponse;

import javax.annotation.CheckForNull;

/**
* @author Kanstantsin Shautsou
*/
public interface UpdateContainerCmd extends SyncDockerCmd<UpdateContainerResponse> {
@CheckForNull
String getContainerId();

@CheckForNull
public Integer getBlkioWeight();

public UpdateContainerCmd withBlkioWeight(Integer blkioWeight);

public UpdateContainerCmd withContainerId(String containerId);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing @nonnull

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it can be set because there is no null checks and null call will work (docker-java wouldn't fail)...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to deny null here (by adding a non-null check in impl and annotate with @nonnull). It doesn't make sense to pass null. What should be done when container id is null in exec?


@CheckForNull
public Integer getCpuPeriod();

public UpdateContainerCmd withCpuPeriod(Integer cpuPeriod);

@CheckForNull
public Integer getCpuQuota();

public UpdateContainerCmd withCpuQuota(Integer cpuQuota);

@CheckForNull
public String getCpusetCpus();

public UpdateContainerCmd withCpusetCpus(String cpusetCpus);

@CheckForNull
public String getCpusetMems();

public UpdateContainerCmd withCpusetMems(String cpusetMems);

@CheckForNull
public Integer getCpuShares();

public UpdateContainerCmd withCpuShares(Integer cpuShares);

@CheckForNull
public Long getKernelMemory();

public UpdateContainerCmd withKernelMemory(Long kernelMemory);

@CheckForNull
public Long getMemory();

public UpdateContainerCmd withMemory(Long memory);

@CheckForNull
public Long getMemoryReservation();

public UpdateContainerCmd withMemoryReservation(Long memoryReservation);

@CheckForNull
Long getMemorySwap();

UpdateContainerCmd withMemorySwap(Long memorySwap);

interface Exec extends DockerCmdSyncExec<UpdateContainerCmd, UpdateContainerResponse> {
}
}
24 changes: 24 additions & 0 deletions src/main/java/com/github/dockerjava/api/model/AuthConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

import javax.annotation.CheckForNull;

@JsonInclude(Include.NON_NULL)
public class AuthConfig {

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

/**
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_22}
*/
@JsonProperty("registrytoken")
private String registrytoken;

public String getUsername() {
return username;
}
Expand Down Expand Up @@ -77,6 +85,22 @@ public AuthConfig withAuth(String auth) {
return this;
}

/**
* @see #registrytoken
*/
@CheckForNull
public String getRegistrytoken() {
return registrytoken;
}

/**
* @see #registrytoken
*/
public AuthConfig withRegistrytoken(String registrytoken) {
this.registrytoken = registrytoken;
return this;
}

@Override
public String toString() {
return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
Expand Down
Loading