X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
* 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.
4 changes: 2 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
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();

public RestartContainerCmd.Exec createRestartContainerCmdExec();

public CommitCmd.Exec createCommitCmdExec();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,5 +462,68 @@ public String getMode() {
public Boolean getRW() {
return rw;
}

/**
* @see #destination
*/
public Mount withDestination(Volume destination) {
this.destination = destination;
return this;
}

/**
* @see #driver
*/
public Mount withDriver(String driver) {
this.driver = driver;
return this;
}

/**
* @see #mode
*/
public Mount withMode(String mode) {
this.mode = mode;
return this;
}

/**
* @see #name
*/
public Mount withName(String name) {
this.name = name;
return this;
}

/**
* @see #rw
*/
public Mount withRw(Boolean rw) {
this.rw = rw;
return this;
}

/**
* @see #source
*/
public Mount withSource(String source) {
this.source = source;
return this;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}

@Override
public boolean equals(Object o) {
return EqualsBuilder.reflectionEquals(this, o);
}

@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
}
}
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,71 @@
package com.github.dockerjava.api.command;

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

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

/**
* @author Kanstantsin Shautsou
* @since {@link RemoteApiVersion#VERSION_1_22}
*/
public interface UpdateContainerCmd extends SyncDockerCmd<UpdateContainerResponse> {
@CheckForNull
String getContainerId();

@CheckForNull
public Integer getBlkioWeight();

public UpdateContainerCmd withBlkioWeight(Integer blkioWeight);

public UpdateContainerCmd withContainerId(@Nonnull String containerId);

@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
X Tutup