Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Add Network.attachable and unit tests #830

Merged
merged 1 commit into from
Jul 20, 2017
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
9 changes: 7 additions & 2 deletions src/main/java/com/spotify/docker/client/messages/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public abstract class Network {
@JsonProperty("Labels")
public abstract ImmutableMap<String, String> labels();

@Nullable
@JsonProperty("Attachable")
public abstract Boolean attachable();

@JsonCreator
static Network create(
@JsonProperty("Name") final String name,
Expand All @@ -83,15 +87,16 @@ static Network create(
@JsonProperty("Options") final Map<String, String> options,
@JsonProperty("Internal") final Boolean internal,
@JsonProperty("EnableIPv6") final Boolean enableIPv6,
@JsonProperty("Labels") final Map<String, String> labels) {
@JsonProperty("Labels") final Map<String, String> labels,
@JsonProperty("Attachable") final Boolean attachable) {
final ImmutableMap<String, Container> containersCopy = containers == null
? null : ImmutableMap.copyOf(containers);
final ImmutableMap<String, String> optionsCopy = options == null
? null : ImmutableMap.copyOf(options);
final ImmutableMap<String, String> labelsCopy = labels == null
? null : ImmutableMap.copyOf(labels);
return new AutoValue_Network(name, id, scope, driver, ipam, containersCopy, optionsCopy,
internal, enableIPv6, labelsCopy);
internal, enableIPv6, labelsCopy, attachable);
}

@AutoValue
Expand Down
51 changes: 51 additions & 0 deletions src/test/java/com/spotify/docker/client/messages/NetworkTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*-
* -\-\-
* docker-client
* --
* Copyright (C) 2016 - 2017 Spotify AB
* --
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -/-/-
*/

package com.spotify.docker.client.messages;

import static com.spotify.docker.FixtureUtil.fixture;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.spotify.docker.client.ObjectMapperProvider;

import org.junit.Test;

public class NetworkTest {

private final ObjectMapper objectMapper = ObjectMapperProvider.objectMapper();

@Test
public void test1_23() throws Exception {
objectMapper.readValue(fixture("fixtures/1.23/network1.json"), Network.class);
objectMapper.readValue(fixture("fixtures/1.23/network2.json"), Network.class);
}

@Test
public void test1_26() throws Exception {
objectMapper.readValue(fixture("fixtures/1.26/network1.json"), Network.class);
objectMapper.readValue(fixture("fixtures/1.26/network2.json"), Network.class);
}

@Test
public void test1_30() throws Exception {
objectMapper.readValue(fixture("fixtures/1.30/network1.json"), Network.class);
objectMapper.readValue(fixture("fixtures/1.30/network2.json"), Network.class);
}
}
32 changes: 32 additions & 0 deletions src/test/resources/fixtures/1.23/network1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"Name": "bridge",
"Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"Internal": false,
"IPAM": {
"Driver": "default",
"Config": [
{
"Subnet": "172.17.0.0/16"
}
]
},
"Containers": {
"39b69226f9d79f5634485fb236a23b2fe4e96a0a94128390a7fbbcc167065867": {
"EndpointID": "ed2419a97c1d9954d05b46e462e7002ea552f216e9b136b80a7db8d98b442eda",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
}
}
14 changes: 14 additions & 0 deletions src/test/resources/fixtures/1.23/network2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Name": "none",
"Id": "e086a3893b05ab69242d3c44e49483a3bbbd3a26b46baa8f61ab797c1088d794",
"Scope": "local",
"Driver": "null",
"EnableIPv6": false,
"Internal": false,
"IPAM": {
"Driver": "default",
"Config": []
},
"Containers": {},
"Options": {}
}
34 changes: 34 additions & 0 deletions src/test/resources/fixtures/1.26/network1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"Name": "bridge",
"Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566",
"Created": "2016-10-19T06:21:00.416543526Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"Internal": false,
"Attachable": false,
"IPAM": {
"Driver": "default",
"Config": [
{
"Subnet": "172.17.0.0/16"
}
]
},
"Containers": {
"39b69226f9d79f5634485fb236a23b2fe4e96a0a94128390a7fbbcc167065867": {
"EndpointID": "ed2419a97c1d9954d05b46e462e7002ea552f216e9b136b80a7db8d98b442eda",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
}
}
16 changes: 16 additions & 0 deletions src/test/resources/fixtures/1.26/network2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Name": "none",
"Id": "e086a3893b05ab69242d3c44e49483a3bbbd3a26b46baa8f61ab797c1088d794",
"Created": "0001-01-01T00:00:00Z",
"Scope": "local",
"Driver": "null",
"EnableIPv6": false,
"Internal": false,
"Attachable": false,
"IPAM": {
"Driver": "default",
"Config": []
},
"Containers": {},
"Options": {}
}
27 changes: 27 additions & 0 deletions src/test/resources/fixtures/1.30/network1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"Name": "bridge",
"Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566",
"Created": "2016-10-19T06:21:00.416543526Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"Internal": false,
"Attachable": false,
"Ingress": false,
"IPAM": {
"Driver": "default",
"Config": [
{
"Subnet": "172.17.0.0/16"
}
]
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
}
}
17 changes: 17 additions & 0 deletions src/test/resources/fixtures/1.30/network2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Name": "none",
"Id": "e086a3893b05ab69242d3c44e49483a3bbbd3a26b46baa8f61ab797c1088d794",
"Created": "0001-01-01T00:00:00Z",
"Scope": "local",
"Driver": "null",
"EnableIPv6": false,
"Internal": false,
"Attachable": false,
"Ingress": false,
"IPAM": {
"Driver": "default",
"Config": []
},
"Containers": {},
"Options": {}
}