From 783972f79572733a7195000844ec28305e5e90c6 Mon Sep 17 00:00:00 2001 From: Sergei Egorov Date: Sun, 21 Jul 2019 15:38:36 +0200 Subject: [PATCH 1/2] Revert breaking binary change of `CreateContainerCmd`. The change was introduced in: https://github.com/docker-java/docker-java/commit/580ea407cc While it is a good change in a long term, 3.1.x should have introduced a deprecation, so that the users have time to update their usages. --- pom.xml | 26 ++ .../api/command/CreateContainerCmd.java | 159 ++++++++++ .../core/command/CreateContainerCmdImpl.java | 285 ++++++++++++++++++ 3 files changed, 470 insertions(+) diff --git a/pom.xml b/pom.xml index 9c23c97b7..39b9516df 100644 --- a/pom.xml +++ b/pom.xml @@ -450,6 +450,32 @@ + + + + com.github.siom79.japicmp + japicmp-maven-plugin + 0.14.1 + + + + com.github.docker-java + docker-java + 3.1.0-rc-4 + jar + + + + + ${project.build.directory}/${project.artifactId}-${project.version}.jar + + + + public + true + + + diff --git a/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java b/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java index c7eb442da..1ade9bf48 100644 --- a/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java +++ b/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java @@ -5,12 +5,17 @@ import com.github.dockerjava.api.model.AuthConfig; import com.github.dockerjava.api.model.Bind; import com.github.dockerjava.api.model.Capability; +import com.github.dockerjava.api.model.Device; import com.github.dockerjava.api.model.ExposedPort; import com.github.dockerjava.api.model.HealthCheck; import com.github.dockerjava.api.model.HostConfig; import com.github.dockerjava.api.model.Link; +import com.github.dockerjava.api.model.LogConfig; +import com.github.dockerjava.api.model.LxcConf; import com.github.dockerjava.api.model.PortBinding; import com.github.dockerjava.api.model.Ports; +import com.github.dockerjava.api.model.RestartPolicy; +import com.github.dockerjava.api.model.Ulimit; import com.github.dockerjava.api.model.Volume; import com.github.dockerjava.api.model.VolumesFrom; @@ -366,6 +371,160 @@ public interface CreateContainerCmd extends SyncDockerCmd devices); + + /** + * Set custom DNS servers + */ + @Deprecated + CreateContainerCmd withDns(String... dns); + + /** + * Set custom DNS servers + */ + @Deprecated + CreateContainerCmd withDns(List dns); + + /** + * Set custom DNS search domains + */ + @Deprecated + CreateContainerCmd withDnsSearch(String... dnsSearch); + + /** + * Set custom DNS search domains + */ + @Deprecated + CreateContainerCmd withDnsSearch(List dnsSearch); + + @Deprecated + CreateContainerCmd withLogConfig(LogConfig logConfig); + + @Deprecated + CreateContainerCmd withLxcConf(LxcConf... lxcConf); + + @Deprecated + CreateContainerCmd withLxcConf(List lxcConf); + + @Deprecated + CreateContainerCmd withOomKillDisable(Boolean oomKillDisable); + + /** + * Set the PID (Process) Namespace mode for the container, 'host': use the host's PID namespace inside the container + */ + @Deprecated + CreateContainerCmd withPidMode(String pidMode); + + @Deprecated + CreateContainerCmd withReadonlyRootfs(Boolean readonlyRootfs); + + /** + * Set custom {@link RestartPolicy} for the container. Defaults to {@link RestartPolicy#noRestart()} + */ + @Deprecated + CreateContainerCmd withRestartPolicy(RestartPolicy restartPolicy); + + @Deprecated + CreateContainerCmd withUlimits(Ulimit... ulimits); + + @Deprecated + CreateContainerCmd withUlimits(List ulimits); + /** * @throws NotFoundException No such container * @throws ConflictException Named container already exists diff --git a/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java index cb129ebd9..d32d23870 100644 --- a/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java +++ b/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java @@ -12,13 +12,18 @@ import com.github.dockerjava.api.model.Bind; import com.github.dockerjava.api.model.Capability; import com.github.dockerjava.api.model.ContainerNetwork; +import com.github.dockerjava.api.model.Device; import com.github.dockerjava.api.model.ExposedPort; import com.github.dockerjava.api.model.ExposedPorts; import com.github.dockerjava.api.model.HealthCheck; import com.github.dockerjava.api.model.HostConfig; import com.github.dockerjava.api.model.Link; +import com.github.dockerjava.api.model.LogConfig; +import com.github.dockerjava.api.model.LxcConf; import com.github.dockerjava.api.model.PortBinding; import com.github.dockerjava.api.model.Ports; +import com.github.dockerjava.api.model.RestartPolicy; +import com.github.dockerjava.api.model.Ulimit; import com.github.dockerjava.api.model.Volume; import com.github.dockerjava.api.model.Volumes; import com.github.dockerjava.api.model.VolumesFrom; @@ -171,6 +176,14 @@ public Bind[] getBinds() { return hostConfig.getBinds(); } + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public Integer getBlkioWeight() { + return hostConfig.getBlkioWeight(); + } + @Override @Deprecated public CreateContainerCmd withBinds(Bind... binds) { @@ -186,6 +199,13 @@ public CreateContainerCmd withBinds(List binds) { return withBinds(binds.toArray(new Bind[binds.size()])); } + @Override + @Deprecated + public CreateContainerCmd withBlkioWeight(Integer blkioWeight) { + hostConfig.withBlkioWeight(blkioWeight); + return this; + } + @Override public CreateContainerCmd withAliases(String... aliases) { this.aliases = Arrays.asList(aliases); @@ -205,6 +225,63 @@ public String[] getCmd() { return cmd; } + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public Integer getCpuPeriod() { + Long result = hostConfig.getCpuPeriod(); + return result != null ? result.intValue() : null; + } + + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public Integer getCpuShares() { + return hostConfig.getCpuShares(); + } + + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public String getCpusetCpus() { + return hostConfig.getCpusetCpus(); + } + + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public String getCpusetMems() { + return hostConfig.getCpusetMems(); + } + + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public Device[] getDevices() { + return hostConfig.getDevices(); + } + + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public String[] getDns() { + return hostConfig.getDns(); + } + + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public String[] getDnsSearch() { + return hostConfig.getDnsSearch(); + } + @Override public CreateContainerCmd withCmd(String... cmd) { checkNotNull(cmd, "cmd was not specified"); @@ -218,6 +295,83 @@ public CreateContainerCmd withCmd(List cmd) { return withCmd(cmd.toArray(new String[0])); } + @Override + @Deprecated + public CreateContainerCmd withContainerIDFile(String containerIDFile) { + hostConfig.withContainerIDFile(containerIDFile); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withCpuPeriod(Integer cpuPeriod) { + hostConfig.withCpuPeriod(cpuPeriod != null ? cpuPeriod.longValue() : null); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withCpuShares(Integer cpuShares) { + hostConfig.withCpuShares(cpuShares); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withCpusetCpus(String cpusetCpus) { + hostConfig.withCpusetCpus(cpusetCpus); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withCpusetMems(String cpusetMems) { + hostConfig.withCpusetMems(cpusetMems); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withDevices(Device... devices) { + hostConfig.withDevices(devices); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withDevices(List devices) { + hostConfig.withDevices(devices); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withDns(String... dns) { + hostConfig.withDns(dns); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withDns(List dns) { + hostConfig.withDns(dns); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withDnsSearch(String... dnsSearch) { + hostConfig.withDnsSearch(dnsSearch); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withDnsSearch(List dnsSearch) { + hostConfig.withDnsSearch(dnsSearch); + return this; + } + @CheckForNull public HealthCheck getHealthcheck() { return healthcheck; @@ -325,6 +479,13 @@ public Integer getStopTimeout() { return stopTimeout; } + @CheckForNull + @Override + @Deprecated + public Ulimit[] getUlimits() { + return hostConfig.getUlimits(); + } + @Override public CreateContainerCmd withStopTimeout(Integer stopTimeout) { this.stopTimeout = stopTimeout; @@ -656,6 +817,20 @@ public CreateContainerCmd withTty(Boolean tty) { return this; } + @Override + @Deprecated + public CreateContainerCmd withUlimits(Ulimit... ulimits) { + hostConfig.withUlimits(ulimits); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withUlimits(List ulimits) { + hostConfig.withUlimits(ulimits); + return this; + } + @CheckForNull @Override @Deprecated @@ -664,6 +839,22 @@ public Boolean getPublishAllPorts() { return hostConfig.getPublishAllPorts(); } + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public Boolean getReadonlyRootfs() { + return hostConfig.getReadonlyRootfs(); + } + + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public RestartPolicy getRestartPolicy() { + return hostConfig.getRestartPolicy(); + } + @Override @Deprecated public CreateContainerCmd withPublishAllPorts(Boolean publishAllPorts) { @@ -672,6 +863,20 @@ public CreateContainerCmd withPublishAllPorts(Boolean publishAllPorts) { return this; } + @Override + @Deprecated + public CreateContainerCmd withReadonlyRootfs(Boolean readonlyRootfs) { + hostConfig.withReadonlyRootfs(readonlyRootfs); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withRestartPolicy(RestartPolicy restartPolicy) { + hostConfig.withRestartPolicy(restartPolicy); + return this; + } + @CheckForNull @Override @Deprecated @@ -726,6 +931,14 @@ public Capability[] getCapDrop() { return hostConfig.getCapDrop(); } + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public String getCgroupParent() { + return hostConfig.getCgroupParent(); + } + @Override @Deprecated public CreateContainerCmd withCapDrop(Capability... capDrop) { @@ -741,6 +954,13 @@ public CreateContainerCmd withCapDrop(List capDrop) { return withCapDrop(capDrop.toArray(new Capability[capDrop.size()])); } + @Override + @Deprecated + public CreateContainerCmd withCgroupParent(String cgroupParent) { + hostConfig.withCgroupParent(cgroupParent); + return this; + } + @Override public HostConfig getHostConfig() { return hostConfig; @@ -772,6 +992,22 @@ public Link[] getLinks() { return hostConfig.getLinks(); } + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public LogConfig getLogConfig() { + return hostConfig.getLogConfig(); + } + + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public LxcConf[] getLxcConf() { + return hostConfig.getLxcConf(); + } + @Override @Deprecated public CreateContainerCmd withLinks(Link... links) { @@ -787,6 +1023,25 @@ public CreateContainerCmd withLinks(List links) { return withLinks(links.toArray(new Link[links.size()])); } + @Override + public CreateContainerCmd withLogConfig(LogConfig logConfig) { + return null; + } + + @Override + @Deprecated + public CreateContainerCmd withLxcConf(LxcConf... lxcConf) { + hostConfig.withLxcConf(lxcConf); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withLxcConf(List lxcConf) { + hostConfig.withLxcConf(lxcConf.toArray(new LxcConf[0])); + return this; + } + @Override public String getIpv6Address() { return ipv6Address; @@ -804,11 +1059,41 @@ public List getOnBuild() { return onBuild; } + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public Boolean getOomKillDisable() { + return hostConfig.getOomKillDisable(); + } + + @CheckForNull + @Override + @Deprecated + @JsonIgnore + public String getPidMode() { + return hostConfig.getPidMode(); + } + public CreateContainerCmdImpl withOnBuild(List onBuild) { this.onBuild = onBuild; return this; } + @Override + @Deprecated + public CreateContainerCmd withOomKillDisable(Boolean oomKillDisable) { + hostConfig.withOomKillDisable(oomKillDisable); + return this; + } + + @Override + @Deprecated + public CreateContainerCmd withPidMode(String pidMode) { + hostConfig.withPidMode(pidMode); + return this; + } + /** * @throws NotFoundException No such container * @throws ConflictException Named container already exists From 62beea455ae7a18d673bc433df8dbd09a1bfefac Mon Sep 17 00:00:00 2001 From: Sergei Egorov Date: Sun, 21 Jul 2019 15:43:15 +0200 Subject: [PATCH 2/2] Fix leftovers --- .../dockerjava/core/command/CreateContainerCmdImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java index d32d23870..74347e900 100644 --- a/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java +++ b/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java @@ -482,6 +482,7 @@ public Integer getStopTimeout() { @CheckForNull @Override @Deprecated + @JsonIgnore public Ulimit[] getUlimits() { return hostConfig.getUlimits(); } @@ -1024,8 +1025,10 @@ public CreateContainerCmd withLinks(List links) { } @Override + @Deprecated public CreateContainerCmd withLogConfig(LogConfig logConfig) { - return null; + hostConfig.withLogConfig(logConfig); + return this; } @Override