Projects
Eulaceura:Factory
docker-client-java
_service:obs_scm:0001-Port-to-latest-version-of...
Sign Up
Log In
Username
Password
Sorry, you are not authorized to perform this action.
×
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0001-Port-to-latest-version-of-Google-AutoValue.patch of Package docker-client-java
From 4652879eb4c1a56f6e2fafdd8f9530b347d447b2 Mon Sep 17 00:00:00 2001 From: Mat Booth <mat.booth@redhat.com> Date: Thu, 7 Mar 2019 14:53:34 +0000 Subject: [PATCH] Port to latest version of Google AutoValue --- pom.xml | 2 +- .../client/messages/ContainerConfig.java | 14 ------------- .../docker/client/messages/mount/Driver.java | 7 ------- .../client/messages/mount/VolumeOptions.java | 7 ------- .../client/messages/swarm/ContainerSpec.java | 16 --------------- .../docker/client/messages/swarm/Driver.java | 7 ------- .../client/messages/swarm/NodeInfo.java | 2 +- .../client/messages/swarm/NodeSpec.java | 14 ++++++------- .../docker/client/messages/swarm/Service.java | 7 ------- .../client/messages/swarm/ServiceSpec.java | 16 --------------- .../client/DefaultDockerClientTest.java | 20 +++++++++++-------- .../client/DefaultDockerClientUnitTest.java | 18 +++++++++++++---- 12 files changed, 34 insertions(+), 96 deletions(-) diff --git a/pom.xml b/pom.xml index 4ac3e11b..3b15d2f4 100644 --- a/pom.xml +++ b/pom.xml @@ -154,7 +154,7 @@ <dependency> <groupId>com.google.auto.value</groupId> <artifactId>auto-value</artifactId> - <version>1.3</version> + <version>1.4.1</version> <scope>provided</scope> </dependency> <dependency> diff --git a/src/main/java/com/spotify/docker/client/messages/ContainerConfig.java b/src/main/java/com/spotify/docker/client/messages/ContainerConfig.java index 8d0c6998..6143ed2b 100644 --- a/src/main/java/com/spotify/docker/client/messages/ContainerConfig.java +++ b/src/main/java/com/spotify/docker/client/messages/ContainerConfig.java @@ -261,20 +261,6 @@ public abstract class ContainerConfig { public abstract Builder image(final String image); - abstract ImmutableSet.Builder<String> volumesBuilder(); - - public Builder addVolume(final String volume) { - volumesBuilder().add(volume); - return this; - } - - public Builder addVolumes(final String... volumes) { - for (final String volume : volumes) { - volumesBuilder().add(volume); - } - return this; - } - /** * @deprecated As of 8.10.0, use {@link #volumes(Set)} or * {@link #volumes(String...)}. diff --git a/src/main/java/com/spotify/docker/client/messages/mount/Driver.java b/src/main/java/com/spotify/docker/client/messages/mount/Driver.java index 2fc6a0c6..dc7dda82 100644 --- a/src/main/java/com/spotify/docker/client/messages/mount/Driver.java +++ b/src/main/java/com/spotify/docker/client/messages/mount/Driver.java @@ -52,13 +52,6 @@ public abstract class Driver { public abstract Builder options(Map<String, String> options); - abstract ImmutableMap.Builder<String, String> optionsBuilder(); - - public Builder addOption(final String name, final String value) { - optionsBuilder().put(name, value); - return this; - } - public abstract Driver build(); } diff --git a/src/main/java/com/spotify/docker/client/messages/mount/VolumeOptions.java b/src/main/java/com/spotify/docker/client/messages/mount/VolumeOptions.java index b9471f25..bf609b89 100644 --- a/src/main/java/com/spotify/docker/client/messages/mount/VolumeOptions.java +++ b/src/main/java/com/spotify/docker/client/messages/mount/VolumeOptions.java @@ -56,13 +56,6 @@ public abstract class VolumeOptions { public abstract Builder labels(Map<String, String> labels); - abstract ImmutableMap.Builder<String, String> labelsBuilder(); - - public Builder addLabel(final String label, final String value) { - labelsBuilder().put(label, value); - return this; - } - public abstract Builder driverConfig(Driver driverConfig); public abstract VolumeOptions build(); diff --git a/src/main/java/com/spotify/docker/client/messages/swarm/ContainerSpec.java b/src/main/java/com/spotify/docker/client/messages/swarm/ContainerSpec.java index 29db35f8..ac5068f7 100644 --- a/src/main/java/com/spotify/docker/client/messages/swarm/ContainerSpec.java +++ b/src/main/java/com/spotify/docker/client/messages/swarm/ContainerSpec.java @@ -137,22 +137,6 @@ public abstract class ContainerSpec { return this; } - abstract ImmutableMap.Builder<String, String> labelsBuilder(); - - public Builder addLabel(final String label, final String value) { - labelsBuilder().put(label, value); - return this; - } - - /** - * @deprecated As of release 7.0.0, replaced by {@link #addLabel(String, String)} ()}. - */ - @Deprecated - public Builder withLabel(final String label, final String value) { - addLabel(label, value); - return this; - } - public abstract Builder hostname(String hostname); public abstract Builder labels(Map<String, String> labels); diff --git a/src/main/java/com/spotify/docker/client/messages/swarm/Driver.java b/src/main/java/com/spotify/docker/client/messages/swarm/Driver.java index 45fbd46f..94517a7d 100644 --- a/src/main/java/com/spotify/docker/client/messages/swarm/Driver.java +++ b/src/main/java/com/spotify/docker/client/messages/swarm/Driver.java @@ -49,13 +49,6 @@ public abstract class Driver { public abstract Builder name(String name); - abstract ImmutableMap.Builder<String, String> optionsBuilder(); - - public Builder addOption(final String name, final String value) { - optionsBuilder().put(name, value); - return this; - } - public abstract Builder options(Map<String, String> options); public abstract Driver build(); diff --git a/src/main/java/com/spotify/docker/client/messages/swarm/NodeInfo.java b/src/main/java/com/spotify/docker/client/messages/swarm/NodeInfo.java index 7e855ba2..1efca3fc 100644 --- a/src/main/java/com/spotify/docker/client/messages/swarm/NodeInfo.java +++ b/src/main/java/com/spotify/docker/client/messages/swarm/NodeInfo.java @@ -61,7 +61,7 @@ public abstract class NodeInfo { public abstract ManagerStatus managerStatus(); @JsonCreator - public static AutoValue_NodeInfo create(@JsonProperty("ID") final String id, + public static NodeInfo create(@JsonProperty("ID") final String id, @JsonProperty("Version") final Version version, @JsonProperty("CreatedAt") final Date createdAt, @JsonProperty("UpdatedAt") final Date updatedAt, diff --git a/src/main/java/com/spotify/docker/client/messages/swarm/NodeSpec.java b/src/main/java/com/spotify/docker/client/messages/swarm/NodeSpec.java index 0368f7b4..ee0699ff 100644 --- a/src/main/java/com/spotify/docker/client/messages/swarm/NodeSpec.java +++ b/src/main/java/com/spotify/docker/client/messages/swarm/NodeSpec.java @@ -53,13 +53,6 @@ public abstract class NodeSpec { public abstract static class Builder { public abstract Builder name(String name); - abstract ImmutableMap.Builder<String, String> labelsBuilder(); - - public Builder addLabel(final String label, final String value) { - labelsBuilder().put(label, value); - return this; - } - public abstract Builder labels(Map<String, String> labels); public abstract Builder role(String role); @@ -74,7 +67,12 @@ public abstract class NodeSpec { } public static NodeSpec.Builder builder(final NodeSpec source) { - return new AutoValue_NodeSpec.Builder(source); + NodeSpec.Builder builder = new AutoValue_NodeSpec.Builder(); + builder.name(source.name()); + builder.labels(source.labels()); + builder.role(source.role()); + builder.availability(source.availability()); + return builder; } @JsonCreator diff --git a/src/main/java/com/spotify/docker/client/messages/swarm/Service.java b/src/main/java/com/spotify/docker/client/messages/swarm/Service.java index 21541f78..27c1c98b 100644 --- a/src/main/java/com/spotify/docker/client/messages/swarm/Service.java +++ b/src/main/java/com/spotify/docker/client/messages/swarm/Service.java @@ -112,13 +112,6 @@ public abstract class Service { public abstract Builder labels(final Map<String, String> labels); - abstract ImmutableMap.Builder<String, String> labelsBuilder(); - - public Builder addLabel(final String label, final String value) { - labelsBuilder().put(label, value); - return this; - } - public abstract Criteria build(); } } diff --git a/src/main/java/com/spotify/docker/client/messages/swarm/ServiceSpec.java b/src/main/java/com/spotify/docker/client/messages/swarm/ServiceSpec.java index 0f333943..acb0ac07 100644 --- a/src/main/java/com/spotify/docker/client/messages/swarm/ServiceSpec.java +++ b/src/main/java/com/spotify/docker/client/messages/swarm/ServiceSpec.java @@ -79,22 +79,6 @@ public abstract class ServiceSpec { return this; } - abstract ImmutableMap.Builder<String, String> labelsBuilder(); - - public Builder addLabel(final String label, final String value) { - labelsBuilder().put(label, value); - return this; - } - - /** - * @deprecated As of release 7.0.0, replaced by {@link #addLabel(String, String)}. - */ - @Deprecated - public Builder withLabel(final String label, final String value) { - addLabel(label, value); - return this; - } - public abstract Builder labels(Map<String, String> labels); /** diff --git a/src/test/java/com/spotify/docker/client/DefaultDockerClientTest.java b/src/test/java/com/spotify/docker/client/DefaultDockerClientTest.java index a7c8dd3d..46c26121 100644 --- a/src/test/java/com/spotify/docker/client/DefaultDockerClientTest.java +++ b/src/test/java/com/spotify/docker/client/DefaultDockerClientTest.java @@ -2813,7 +2813,7 @@ public class DefaultDockerClientTest { .build(); final ContainerConfig volumeConfig = ContainerConfig.builder() .image(BUSYBOX_LATEST) - .addVolume("/foo") + .volumes("/foo") .hostConfig(hostConfig) .build(); final String id = sut.createContainer(volumeConfig, randomName()).id(); @@ -2945,7 +2945,7 @@ public class DefaultDockerClientTest { .build(); final ContainerConfig volumeConfig = ContainerConfig.builder() .image(BUSYBOX_LATEST) - .addVolume(anonVolumeTo) + .volumes(anonVolumeTo) .hostConfig(hostConfig) .build(); final String id = sut.createContainer(volumeConfig, randomName()).id(); @@ -3106,7 +3106,7 @@ public class DefaultDockerClientTest { final ContainerConfig volumeConfig = ContainerConfig.builder() .image(BUSYBOX_LATEST) - .addVolume("/foo") + .volumes("/foo") .cmd("touch", "/foo/bar") .build(); sut.createContainer(volumeConfig, volumeContainer); @@ -3145,7 +3145,7 @@ public class DefaultDockerClientTest { final ContainerConfig volumeConfig = ContainerConfig.builder() .image(BUSYBOX_LATEST) - .addVolume("/foo") + .volumes("/foo") // TODO (mbrown): remove sleep - added to make sure container is still alive when attaching //.cmd("ls", "-la") .cmd("sh", "-c", "ls -la; sleep 3") @@ -5297,13 +5297,15 @@ public class DefaultDockerClientTest { public void testInspectService() throws Exception { requireDockerApiVersionAtLeast("1.24", "swarm support"); + Map<String,String> opts = new HashMap<>(); + opts.put("max-file", "3"); + opts.put("max-size", "10M"); final String[] commandLine = {"ping", "-c4", "localhost"}; final TaskSpec taskSpec = TaskSpec .builder() .containerSpec(ContainerSpec.builder().image("alpine") .command(commandLine).build()) - .logDriver(Driver.builder().name("json-file").addOption("max-file", "3") - .addOption("max-size", "10M").build()) + .logDriver(Driver.builder().name("json-file").options(opts).build()) .resources(ResourceRequirements.builder() .limits(com.spotify.docker.client.messages.swarm.Resources.builder() .memoryBytes(10 * 1024 * 1024L).build()) @@ -5481,13 +5483,15 @@ public class DefaultDockerClientTest { final ServiceSpec spec = createServiceSpec(serviceName, labels); sut.createService(spec); - final List<Service> services = sut.listServices(Service.find().addLabel("foo", "bar").build()); + Map<String, String> labels2 = new HashMap<>(); + labels2.put("foo", "bar"); + final List<Service> services = sut.listServices(Service.find().labels(labels2).build()); assertThat(services.size(), is(1)); assertThat(services.get(0).spec().labels().get("foo"), is("bar")); final List<Service> notFoundServices = sut.listServices(Service.find() - .addLabel("bar", "foo").build()); + .labels(labels2).build()); assertThat(notFoundServices.size(), is(0)); } diff --git a/src/test/java/com/spotify/docker/client/DefaultDockerClientUnitTest.java b/src/test/java/com/spotify/docker/client/DefaultDockerClientUnitTest.java index 23867eb5..abbd0951 100644 --- a/src/test/java/com/spotify/docker/client/DefaultDockerClientUnitTest.java +++ b/src/test/java/com/spotify/docker/client/DefaultDockerClientUnitTest.java @@ -85,8 +85,10 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; import okhttp3.HttpUrl; @@ -502,8 +504,10 @@ public class DefaultDockerClientUnitTest { assertThat(node.spec().availability(), equalTo("active")); assertThat(node.spec().labels(), hasKey(equalTo("foo"))); + Map<String,String> labels = new HashMap<>(); + labels.put("foobar", "foobar"); final NodeSpec updatedNodeSpec = NodeSpec.builder(node.spec()) - .addLabel("foobar", "foobar") + .labels(labels) .build(); enqueueServerApiVersion("1.28"); @@ -523,8 +527,10 @@ public class DefaultDockerClientUnitTest { enqueueServerApiResponse(500, errorMessage); + Map<String,String> labels = new HashMap<>(); + labels.put("foo", "baz"); final NodeSpec nodeSpec = NodeSpec.builder() - .addLabel("foo", "baz") + .labels(labels) .name("foobar") .availability("active") .role("manager") @@ -540,8 +546,10 @@ public class DefaultDockerClientUnitTest { enqueueServerApiVersion("1.28"); enqueueServerApiError(404, "Error updating node: '24ifsmvkjbyhk'"); + Map<String,String> labels = new HashMap<>(); + labels.put("foo", "baz"); final NodeSpec nodeSpec = NodeSpec.builder() - .addLabel("foo", "baz") + .labels(labels) .name("foobar") .availability("active") .role("manager") @@ -557,9 +565,11 @@ public class DefaultDockerClientUnitTest { enqueueServerApiVersion("1.28"); enqueueServerApiError(503, "Error updating node: '24ifsmvkjbyhk'"); + Map<String,String> labels = new HashMap<>(); + labels.put("foo", "baz"); final NodeSpec nodeSpec = NodeSpec.builder() .name("foobar") - .addLabel("foo", "baz") + .labels(labels) .availability("active") .role("manager") .build(); -- 2.20.1
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2