From e4337e2824e39dd27d8117016ba0b87e0aa7ed50 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Tue, 3 Oct 2023 21:19:50 +0200 Subject: [PATCH] Adopt to the updated api-model See https://github.com/gesellix/docker-client/commit/359485188fb739d697fb2151e0447eb1e080145f (PR https://github.com/gesellix/docker-client/pull/562) --- client/build.gradle.kts | 8 +++--- .../container/ManageContainerClient.groovy | 28 ++++++++++--------- .../client/stack/DeployConfigReader.groovy | 10 +++++-- .../client/volume/ManageVolumeClient.java | 4 ++- .../client/container/ManageContainer.java | 4 +-- .../ManageContainerClientTest.groovy | 6 ++-- .../stack/DeployConfigReaderTest.groovy | 2 ++ .../volume/ManageVolumeClientTest.groovy | 4 +-- integration-test/build.gradle.kts | 8 +++--- .../DockerContainerIntegrationSpec.groovy | 10 +++++-- 10 files changed, 50 insertions(+), 34 deletions(-) diff --git a/client/build.gradle.kts b/client/build.gradle.kts index ea17a66f3..237b986e4 100644 --- a/client/build.gradle.kts +++ b/client/build.gradle.kts @@ -15,17 +15,17 @@ dependencies { constraints { implementation("de.gesellix:docker-engine") { version { - strictly("[2023-07-01T01-01-01,)") + strictly("[2023-10-01T01-01-01,)") } } implementation("de.gesellix:docker-filesocket") { version { - strictly("[2023-07-01T01-01-01,)") + strictly("[2023-09-01T01-01-01,)") } } implementation("de.gesellix:docker-remote-api-model-1-41") { version { - strictly("[2023-07-01T01-01-01,)") + strictly("[2023-10-01T01-01-01,)") } } implementation("org.slf4j:slf4j-api") { @@ -120,7 +120,7 @@ dependencies { implementation("org.bouncycastle:bcpkix-jdk18on:1.76") - testImplementation("de.gesellix:testutil:[2023-07-01T01-01-01,)") + testImplementation("de.gesellix:testutil:[2023-09-01T01-01-01,)") testImplementation("org.junit.platform:junit-platform-launcher:1.10.0") testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") diff --git a/client/src/main/groovy/de/gesellix/docker/client/container/ManageContainerClient.groovy b/client/src/main/groovy/de/gesellix/docker/client/container/ManageContainerClient.groovy index 9fefdba1e..8fd912214 100644 --- a/client/src/main/groovy/de/gesellix/docker/client/container/ManageContainerClient.groovy +++ b/client/src/main/groovy/de/gesellix/docker/client/container/ManageContainerClient.groovy @@ -6,7 +6,6 @@ import de.gesellix.docker.client.repository.RepositoryTagParser import de.gesellix.docker.engine.AttachConfig import de.gesellix.docker.engine.EngineClient import de.gesellix.docker.engine.EngineResponse -import de.gesellix.docker.remote.api.ContainerChangeResponseItem import de.gesellix.docker.remote.api.ContainerConfig import de.gesellix.docker.remote.api.ContainerCreateRequest import de.gesellix.docker.remote.api.ContainerCreateResponse @@ -20,6 +19,7 @@ import de.gesellix.docker.remote.api.EngineApiClient import de.gesellix.docker.remote.api.ExecConfig import de.gesellix.docker.remote.api.ExecInspectResponse import de.gesellix.docker.remote.api.ExecStartConfig +import de.gesellix.docker.remote.api.FilesystemChange import de.gesellix.docker.remote.api.HealthConfig import de.gesellix.docker.remote.api.IdResponse import de.gesellix.docker.remote.api.client.ContainerApi @@ -199,10 +199,10 @@ class ManageContainerClient implements ManageContainer { } @Override - EngineResponseContent> diff(String containerId) { + EngineResponseContent> diff(String containerId) { log.info("docker diff") - List containerChanges = client.containerApi.containerChanges(containerId) - return new EngineResponseContent>(containerChanges) + List containerChanges = client.containerApi.containerChanges(containerId) + return new EngineResponseContent>(containerChanges) } @Override @@ -265,6 +265,7 @@ class ManageContainerClient implements ManageContainer { true, true, null, + null, (execConfig.Tty ?: false) as Boolean, null, command, @@ -276,7 +277,8 @@ class ManageContainerClient implements ManageContainer { String execId = execCreateResult.content.id ExecStartConfig execStartConfig = new ExecStartConfig( (execConfig.Detach ?: false) as Boolean, - actualExecConfig.tty) + actualExecConfig.tty, + null) startExec(execId, execStartConfig, callback, timeout) return execCreateResult } @@ -333,14 +335,14 @@ class ManageContainerClient implements ManageContainer { // def multiplexStreams = !inspectContainer(container).content.config.tty client.containerApi.containerLogs(container, - actualQuery.follow as Boolean, - actualQuery.stdout as Boolean, - actualQuery.stderr as Boolean, - actualQuery.since as Integer, - actualQuery.until as Integer, - actualQuery.timestamps as Boolean, - actualQuery.tail as String, - callback, timeout.toMillis()) + actualQuery.follow as Boolean, + actualQuery.stdout as Boolean, + actualQuery.stderr as Boolean, + actualQuery.since as Integer, + actualQuery.until as Integer, + actualQuery.timestamps as Boolean, + actualQuery.tail as String, + callback, timeout.toMillis()) } @Override diff --git a/client/src/main/groovy/de/gesellix/docker/client/stack/DeployConfigReader.groovy b/client/src/main/groovy/de/gesellix/docker/client/stack/DeployConfigReader.groovy index e80501f3d..185c2f958 100644 --- a/client/src/main/groovy/de/gesellix/docker/client/stack/DeployConfigReader.groovy +++ b/client/src/main/groovy/de/gesellix/docker/client/stack/DeployConfigReader.groovy @@ -382,12 +382,13 @@ class DeployConfigReader { Long timeout = null Long interval = null Long startPeriod = null + Long startInterval = null if (healthcheck.disable) { if (healthcheck.test?.parts) { throw new IllegalArgumentException("test and disable can't be set at the same time") } - return new HealthConfig(["NONE"], null, null, null, null) + return new HealthConfig(["NONE"], null, null, null, null, null) } if (healthcheck.timeout) { @@ -402,13 +403,18 @@ class DeployConfigReader { if (healthcheck.startPeriod) { startPeriod = parseDuration(healthcheck.startPeriod).toNanos() } + // TODO add this one +// if (healthcheck.startInterval) { +// startInterval = parseDuration(healthcheck.startInterval).toNanos() +// } return new HealthConfig( healthcheck.test.parts, interval ?: 0, timeout ?: 0, retries, - startPeriod + startPeriod, + startInterval ) } diff --git a/client/src/main/groovy/de/gesellix/docker/client/volume/ManageVolumeClient.java b/client/src/main/groovy/de/gesellix/docker/client/volume/ManageVolumeClient.java index 889e6cd6e..cd0602c11 100644 --- a/client/src/main/groovy/de/gesellix/docker/client/volume/ManageVolumeClient.java +++ b/client/src/main/groovy/de/gesellix/docker/client/volume/ManageVolumeClient.java @@ -1,6 +1,7 @@ package de.gesellix.docker.client.volume; import de.gesellix.docker.client.EngineResponseContent; +import de.gesellix.docker.remote.api.ClusterVolumeSpec; import de.gesellix.docker.remote.api.EngineApiClient; import de.gesellix.docker.remote.api.Volume; import de.gesellix.docker.remote.api.VolumeCreateOptions; @@ -72,7 +73,8 @@ public EngineResponseContent createVolume(Map config) { config == null ? null : (String) config.get("Name"), config == null ? null : (String) config.get("Driver"), config == null ? null : (Map) config.get("DriverOpts"), - config == null ? null : (Map) config.get("Labels"))); + config == null ? null : (Map) config.get("Labels"), + config == null ? null : (ClusterVolumeSpec) config.get("ClusterVolumeSpec"))); } @Override diff --git a/client/src/main/java/de/gesellix/docker/client/container/ManageContainer.java b/client/src/main/java/de/gesellix/docker/client/container/ManageContainer.java index 9959e0cb5..55208730a 100644 --- a/client/src/main/java/de/gesellix/docker/client/container/ManageContainer.java +++ b/client/src/main/java/de/gesellix/docker/client/container/ManageContainer.java @@ -3,7 +3,6 @@ import de.gesellix.docker.client.EngineResponseContent; import de.gesellix.docker.engine.AttachConfig; import de.gesellix.docker.engine.EngineResponse; -import de.gesellix.docker.remote.api.ContainerChangeResponseItem; import de.gesellix.docker.remote.api.ContainerCreateRequest; import de.gesellix.docker.remote.api.ContainerCreateResponse; import de.gesellix.docker.remote.api.ContainerInspectResponse; @@ -15,6 +14,7 @@ import de.gesellix.docker.remote.api.ExecConfig; import de.gesellix.docker.remote.api.ExecInspectResponse; import de.gesellix.docker.remote.api.ExecStartConfig; +import de.gesellix.docker.remote.api.FilesystemChange; import de.gesellix.docker.remote.api.IdResponse; import de.gesellix.docker.remote.api.client.ContainerApi; import de.gesellix.docker.remote.api.core.Frame; @@ -62,7 +62,7 @@ void attach(String containerId, EngineResponseContent createContainer(ContainerCreateRequest containerCreateRequest, String name, String authBase64Encoded); - EngineResponseContent> diff(String container); + EngineResponseContent> diff(String container); EngineResponseContent createExec(String container, ExecConfig execConfig); diff --git a/client/src/test/groovy/de/gesellix/docker/client/container/ManageContainerClientTest.groovy b/client/src/test/groovy/de/gesellix/docker/client/container/ManageContainerClientTest.groovy index a01061d12..6098c81be 100644 --- a/client/src/test/groovy/de/gesellix/docker/client/container/ManageContainerClientTest.groovy +++ b/client/src/test/groovy/de/gesellix/docker/client/container/ManageContainerClientTest.groovy @@ -213,7 +213,7 @@ class ManageContainerClientTest extends Specification { given: def execApi = Mock(ExecApi) client.execApi >> execApi - def execStartConfig = new ExecStartConfig(true, false) + def execStartConfig = new ExecStartConfig(true, false, null) def callback = Mock(StreamCallback) when: @@ -251,12 +251,12 @@ class ManageContainerClientTest extends Specification { then: 1 * execApi.containerExec("container-id", new ExecConfig(false, true, true, - null, false, + null, null, false, null, ["command", "line"], null, null, null)) >> idResponse then: 1 * execApi.execStart("exec-id", - new ExecStartConfig(false, false), + new ExecStartConfig(false, false, null), callback, 1000) and: exec.content == idResponse diff --git a/client/src/test/groovy/de/gesellix/docker/client/stack/DeployConfigReaderTest.groovy b/client/src/test/groovy/de/gesellix/docker/client/stack/DeployConfigReaderTest.groovy index c30de5942..2d8e9ca2e 100644 --- a/client/src/test/groovy/de/gesellix/docker/client/stack/DeployConfigReaderTest.groovy +++ b/client/src/test/groovy/de/gesellix/docker/client/stack/DeployConfigReaderTest.groovy @@ -562,6 +562,7 @@ class DeployConfigReaderTest extends Specification { Duration.of(2, ChronoUnit.MILLIS).toNanos().longValue(), Duration.of(30, ChronoUnit.SECONDS).toNanos().longValue(), 10, + null, null ) } @@ -575,6 +576,7 @@ class DeployConfigReaderTest extends Specification { null, null, null, + null, null ) } diff --git a/client/src/test/groovy/de/gesellix/docker/client/volume/ManageVolumeClientTest.groovy b/client/src/test/groovy/de/gesellix/docker/client/volume/ManageVolumeClientTest.groovy index 4c1b05c12..3e02bd19c 100644 --- a/client/src/test/groovy/de/gesellix/docker/client/volume/ManageVolumeClientTest.groovy +++ b/client/src/test/groovy/de/gesellix/docker/client/volume/ManageVolumeClientTest.groovy @@ -79,7 +79,7 @@ class ManageVolumeClientTest extends Specification { DriverOpts: [:]]) then: - 1 * volumeApi.volumeCreate(new VolumeCreateOptions("my-fancy-volume", "local", [:], null)) >> volumeResponse + 1 * volumeApi.volumeCreate(new VolumeCreateOptions("my-fancy-volume", "local", [:], null, null)) >> volumeResponse volume.content == volumeResponse } @@ -88,7 +88,7 @@ class ManageVolumeClientTest extends Specification { def volumeApi = Mock(VolumeApi) client.volumeApi >> volumeApi def volumeResponse = Mock(Volume) - def volumeConfig = new VolumeCreateOptions("my-volume", "local", [:], [:]) + def volumeConfig = new VolumeCreateOptions("my-volume", "local", [:], [:], null) when: def volume = service.createVolume(volumeConfig) diff --git a/integration-test/build.gradle.kts b/integration-test/build.gradle.kts index 4060b17e4..09c3338d7 100644 --- a/integration-test/build.gradle.kts +++ b/integration-test/build.gradle.kts @@ -13,17 +13,17 @@ dependencies { constraints { implementation("de.gesellix:docker-engine") { version { - strictly("[2023-07-01T01-01-01,)") + strictly("[2023-10-01T01-01-01,)") } } implementation("de.gesellix:docker-filesocket") { version { - strictly("[2023-07-01T01-01-01,)") + strictly("[2023-09-30T01-01-01,)") } } implementation("de.gesellix:docker-remote-api-model-1-41") { version { - strictly("[2023-07-01T01-01-01,)") + strictly("[2023-10-01T01-01-01,)") } } implementation("org.slf4j:slf4j-api") { @@ -86,7 +86,7 @@ dependencies { runtimeOnly("ch.qos.logback:logback-classic:[1.2,2)!!1.3.8") testImplementation("de.gesellix:docker-registry:2023-10-02T08-55-00") - testImplementation("de.gesellix:testutil:[2023-07-01T01-01-01,)") + testImplementation("de.gesellix:testutil:[2023-09-01T01-01-01,)") testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") testRuntimeOnly("net.bytebuddy:byte-buddy:1.14.8") testImplementation("org.apache.commons:commons-lang3:3.13.0") diff --git a/integration-test/src/test/groovy/de/gesellix/docker/client/DockerContainerIntegrationSpec.groovy b/integration-test/src/test/groovy/de/gesellix/docker/client/DockerContainerIntegrationSpec.groovy index 00a9b248d..8c46ac79e 100644 --- a/integration-test/src/test/groovy/de/gesellix/docker/client/DockerContainerIntegrationSpec.groovy +++ b/integration-test/src/test/groovy/de/gesellix/docker/client/DockerContainerIntegrationSpec.groovy @@ -3,6 +3,7 @@ package de.gesellix.docker.client import de.gesellix.docker.client.container.ArchiveUtil import de.gesellix.docker.client.testutil.TeeOutputStream import de.gesellix.docker.engine.AttachConfig +import de.gesellix.docker.remote.api.ChangeType import de.gesellix.docker.remote.api.ContainerCreateRequest import de.gesellix.docker.remote.api.ContainerUpdateRequest import de.gesellix.docker.remote.api.CreateImageInfo @@ -179,7 +180,7 @@ class DockerContainerIntegrationSpec extends Specification { def aChange = changes.find { it.path?.endsWith("/change.txt") } - if (aChange != null && aChange.kind >= 0) { + if (aChange != null && aChange.kind in ChangeType.values()) { latch.countDown() return } else { @@ -547,6 +548,7 @@ class DockerContainerIntegrationSpec extends Specification { null, null, null, + null, ['echo "hello exec!"'], null, null, @@ -573,6 +575,7 @@ class DockerContainerIntegrationSpec extends Specification { true, true, null, + null, false, null, ["ls", "-lisah", "/"], @@ -606,7 +609,7 @@ class DockerContainerIntegrationSpec extends Specification { } when: - def execStartConfig = new ExecStartConfig(false, false) + def execStartConfig = new ExecStartConfig(false, false, null) dockerClient.startExec(execId, execStartConfig, callback, Duration.of(5, ChronoUnit.SECONDS)) latch.await(10, SECONDS) @@ -641,6 +644,7 @@ class DockerContainerIntegrationSpec extends Specification { true, true, null, + null, true, null, execCmd, @@ -676,7 +680,7 @@ class DockerContainerIntegrationSpec extends Specification { } when: - def execStartConfig = new ExecStartConfig(false, true) + def execStartConfig = new ExecStartConfig(false, true, null) dockerClient.startExec(execId, execStartConfig, attachConfig) // dockerClient.startExec(execId, execStartConfig, callback, Duration.of(1, ChronoUnit.MINUTES)) onSinkClosed.await(5, SECONDS)