Skip to content

Commit

Permalink
Adopt to the updated api-model
Browse files Browse the repository at this point in the history
See 3594851 (PR #562)
  • Loading branch information
gesellix committed Oct 3, 2023
1 parent 2e3c856 commit e4337e2
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 34 deletions.
8 changes: 4 additions & 4 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -199,10 +199,10 @@ class ManageContainerClient implements ManageContainer {
}

@Override
EngineResponseContent<List<ContainerChangeResponseItem>> diff(String containerId) {
EngineResponseContent<List<FilesystemChange>> diff(String containerId) {
log.info("docker diff")
List<ContainerChangeResponseItem> containerChanges = client.containerApi.containerChanges(containerId)
return new EngineResponseContent<List<ContainerChangeResponseItem>>(containerChanges)
List<FilesystemChange> containerChanges = client.containerApi.containerChanges(containerId)
return new EngineResponseContent<List<FilesystemChange>>(containerChanges)
}

@Override
Expand Down Expand Up @@ -265,6 +265,7 @@ class ManageContainerClient implements ManageContainer {
true,
true,
null,
null,
(execConfig.Tty ?: false) as Boolean,
null,
command,
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -72,7 +73,8 @@ public EngineResponseContent<Volume> createVolume(Map<String, Object> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -62,7 +62,7 @@ void attach(String containerId,

EngineResponseContent<ContainerCreateResponse> createContainer(ContainerCreateRequest containerCreateRequest, String name, String authBase64Encoded);

EngineResponseContent<List<ContainerChangeResponseItem>> diff(String container);
EngineResponseContent<List<FilesystemChange>> diff(String container);

EngineResponseContent<IdResponse> createExec(String container, ExecConfig execConfig);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
Expand All @@ -575,6 +576,7 @@ class DeployConfigReaderTest extends Specification {
null,
null,
null,
null,
null
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions integration-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -547,6 +548,7 @@ class DockerContainerIntegrationSpec extends Specification {
null,
null,
null,
null,
['echo "hello exec!"'],
null,
null,
Expand All @@ -573,6 +575,7 @@ class DockerContainerIntegrationSpec extends Specification {
true,
true,
null,
null,
false,
null,
["ls", "-lisah", "/"],
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -641,6 +644,7 @@ class DockerContainerIntegrationSpec extends Specification {
true,
true,
null,
null,
true,
null,
execCmd,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e4337e2

Please sign in to comment.