X Tutup
Skip to content

Commit a1d1e3d

Browse files
committed
Fixes Issue docker-java#584
Adds RootDir property to GraphData. This was seen on a CentOS system without aufs support.
1 parent 0758623 commit a1d1e3d

File tree

2 files changed

+122
-101
lines changed

2 files changed

+122
-101
lines changed

src/main/java/com/github/dockerjava/api/command/GraphData.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
package com.github.dockerjava.api.command;
22

3-
import com.fasterxml.jackson.annotation.JsonProperty;
3+
import javax.annotation.CheckForNull;
4+
45
import org.apache.commons.lang.builder.EqualsBuilder;
56
import org.apache.commons.lang.builder.HashCodeBuilder;
67
import org.apache.commons.lang.builder.ToStringBuilder;
78

8-
import javax.annotation.CheckForNull;
9+
import com.fasterxml.jackson.annotation.JsonProperty;
910

1011
/**
1112
* part of {@link GraphDriver}
13+
*
1214
* @author Kanstantsin Shautsou
1315
*/
1416
public class GraphData {
17+
18+
@JsonProperty("RootDir")
19+
private String rootDir;
20+
1521
@JsonProperty("DeviceId")
1622
private String deviceId;
1723

@@ -21,6 +27,22 @@ public class GraphData {
2127
@JsonProperty("DeviceSize")
2228
private String deviceSize;
2329

30+
/**
31+
* @see #rootDir
32+
*/
33+
@CheckForNull
34+
public String getRootDir() {
35+
return rootDir;
36+
}
37+
38+
/**
39+
* @see #deviceId
40+
*/
41+
public GraphData withRootDir(String rootDir) {
42+
this.rootDir = rootDir;
43+
return this;
44+
}
45+
2446
/**
2547
* @see #deviceId
2648
*/
Lines changed: 98 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
package com.github.dockerjava.api.command;
22

3-
import com.fasterxml.jackson.databind.JavaType;
4-
import com.fasterxml.jackson.databind.ObjectMapper;
5-
import com.github.dockerjava.api.model.ContainerConfig;
6-
import org.testng.annotations.Test;
7-
8-
import java.io.IOException;
9-
import java.util.Collections;
10-
113
import static com.github.dockerjava.core.RemoteApiVersion.VERSION_1_22;
124
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
135
import static org.hamcrest.MatcherAssert.assertThat;
@@ -21,65 +13,72 @@
2113
import static org.hamcrest.Matchers.notNullValue;
2214
import static org.hamcrest.Matchers.nullValue;
2315

16+
import java.io.IOException;
17+
import java.util.Collections;
18+
19+
import org.testng.annotations.Test;
20+
21+
import com.fasterxml.jackson.databind.JavaType;
22+
import com.fasterxml.jackson.databind.ObjectMapper;
23+
import com.github.dockerjava.api.model.ContainerConfig;
24+
2425
/**
2526
* @author Kanstantsin Shautsou
2627
*/
2728
public class InspectImageResponseTest {
29+
2830
@Test
2931
public void serder1_22Json() throws IOException {
3032
final ObjectMapper mapper = new ObjectMapper();
3133
final JavaType type = mapper.getTypeFactory().constructType(InspectImageResponse.class);
3234

33-
final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_22,
34-
"images/image1/inspect1.json",
35-
type
36-
);
37-
38-
final ContainerConfig config = new ContainerConfig()
39-
.withAttachStderr(false)
40-
.withAttachStdin(false)
41-
.withAttachStdout(false)
42-
.withCmd(null)
43-
.withDomainName("")
44-
.withEntrypoint(null)
45-
.withEnv(new String[]{"HOME=/", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"})
46-
.withExposedPorts(null)
47-
.withHostName("aee9ba801acc")
48-
.withImage("511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158")
49-
.withLabels(null)
50-
.withMacAddress(null)
51-
.withNetworkDisabled(null)
52-
.withOnBuild(new String[]{})
53-
.withStdinOpen(false)
54-
.withPortSpecs(null)
55-
.withStdInOnce(false)
56-
.withTty(false)
57-
.withUser("")
58-
.withVolumes(null)
59-
.withWorkingDir("");
60-
61-
final ContainerConfig containerConfig = new ContainerConfig()
62-
.withAttachStderr(false)
63-
.withAttachStdin(false)
64-
.withAttachStdout(false)
65-
.withCmd(new String[]{"/bin/sh", "-c", "#(nop) MAINTAINER hack@worldticket.net"})
66-
.withDomainName("")
67-
.withEntrypoint(null)
68-
.withEnv(new String[]{"HOME=/", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"})
69-
.withExposedPorts(null)
70-
.withHostName("aee9ba801acc")
71-
.withImage("511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158")
72-
.withLabels(null)
73-
.withMacAddress(null)
74-
.withNetworkDisabled(null)
75-
.withOnBuild(new String[]{})
76-
.withStdinOpen(false)
77-
.withPortSpecs(null)
78-
.withStdInOnce(false)
79-
.withTty(false)
80-
.withUser("")
81-
.withVolumes(null)
82-
.withWorkingDir("");
35+
final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_22, "images/image1/inspect1.json", type);
36+
37+
final ContainerConfig config = new ContainerConfig().withAttachStderr(false)
38+
.withAttachStdin(false)
39+
.withAttachStdout(false)
40+
.withCmd(null)
41+
.withDomainName("")
42+
.withEntrypoint(null)
43+
.withEnv(new String[] { "HOME=/",
44+
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" })
45+
.withExposedPorts(null)
46+
.withHostName("aee9ba801acc")
47+
.withImage("511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158")
48+
.withLabels(null)
49+
.withMacAddress(null)
50+
.withNetworkDisabled(null)
51+
.withOnBuild(new String[] {})
52+
.withStdinOpen(false)
53+
.withPortSpecs(null)
54+
.withStdInOnce(false)
55+
.withTty(false)
56+
.withUser("")
57+
.withVolumes(null)
58+
.withWorkingDir("");
59+
60+
final ContainerConfig containerConfig = new ContainerConfig().withAttachStderr(false)
61+
.withAttachStdin(false)
62+
.withAttachStdout(false)
63+
.withCmd(new String[] { "/bin/sh", "-c", "#(nop) MAINTAINER hack@worldticket.net" })
64+
.withDomainName("")
65+
.withEntrypoint(null)
66+
.withEnv(new String[] { "HOME=/",
67+
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" })
68+
.withExposedPorts(null)
69+
.withHostName("aee9ba801acc")
70+
.withImage("511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158")
71+
.withLabels(null)
72+
.withMacAddress(null)
73+
.withNetworkDisabled(null)
74+
.withOnBuild(new String[] {})
75+
.withStdinOpen(false)
76+
.withPortSpecs(null)
77+
.withStdInOnce(false)
78+
.withTty(false)
79+
.withUser("")
80+
.withVolumes(null)
81+
.withWorkingDir("");
8382

8483
assertThat(inspectImage, notNullValue());
8584
assertThat(inspectImage.getArch(), is("amd64"));
@@ -113,68 +112,53 @@ public void serder1_22Json() throws IOException {
113112

114113
assertThat(inspectImage.getVirtualSize(), is(0L));
115114

116-
117115
final InspectImageResponse inspectImageResponse = new InspectImageResponse().withArch("amd64")
118-
.withAuthor("hack@worldticket.net")
119-
.withComment("")
120-
.withConfig(config)
121-
.withContainer("aee9ba801acca0e648ffd91df204ba82ae85d97608a4864a019e2004d7e1b133")
122-
.withContainerConfig(containerConfig)
123-
.withCreated("2014-04-29T19:59:10.84997669Z")
124-
.withDockerVersion("0.8.1")
125-
.withId("sha256:ee45fe0d1fcdf1a0f9c2d1e36c6f4b3202bbb2032f14d7c9312b27bfcf6aee24")
126-
.withOs("linux")
127-
.withParent("")
128-
.withSize(0L)
129-
.withRepoTags(Collections.singletonList("hackmann/empty:latest"))
130-
.withRepoDigests(Collections.<String>emptyList())
131-
.withVirtualSize(0L)
132-
.withGraphDriver(aufsGraphDriver);
116+
.withAuthor("hack@worldticket.net")
117+
.withComment("")
118+
.withConfig(config)
119+
.withContainer("aee9ba801acca0e648ffd91df204ba82ae85d97608a4864a019e2004d7e1b133")
120+
.withContainerConfig(containerConfig)
121+
.withCreated("2014-04-29T19:59:10.84997669Z")
122+
.withDockerVersion("0.8.1")
123+
.withId("sha256:ee45fe0d1fcdf1a0f9c2d1e36c6f4b3202bbb2032f14d7c9312b27bfcf6aee24")
124+
.withOs("linux")
125+
.withParent("")
126+
.withSize(0L)
127+
.withRepoTags(Collections.singletonList("hackmann/empty:latest"))
128+
.withRepoDigests(Collections.<String> emptyList())
129+
.withVirtualSize(0L)
130+
.withGraphDriver(aufsGraphDriver);
133131

134132
assertThat(inspectImage, equalTo(inspectImageResponse));
135133
}
136134

137-
138135
@Test
139136
public void serder1_22_doc() throws IOException {
140137
final ObjectMapper mapper = new ObjectMapper();
141138
final JavaType type = mapper.getTypeFactory().constructType(InspectImageResponse.class);
142139

143-
final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_22,
144-
"images/docImage/doc.json",
145-
type
146-
);
140+
final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_22, "images/docImage/doc.json", type);
147141

148142
assertThat(inspectImage, notNullValue());
149143

150144
assertThat(inspectImage.getRepoDigests(), hasSize(1));
151145
assertThat(inspectImage.getRepoDigests(),
152-
contains("localhost:5000/test/busybox/example@" +
153-
"sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf")
154-
);
146+
contains("localhost:5000/test/busybox/example@" + "sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"));
155147

156148
assertThat(inspectImage.getRepoTags(), hasSize(3));
157-
assertThat(inspectImage.getRepoTags(), containsInAnyOrder(
158-
"example:1.0",
159-
"example:latest",
160-
"example:stable"
161-
));
149+
assertThat(inspectImage.getRepoTags(), containsInAnyOrder("example:1.0", "example:latest", "example:stable"));
162150
}
163151

164152
@Test
165153
public void serder1_22_inspect_doc() throws IOException {
166154
final ObjectMapper mapper = new ObjectMapper();
167155
final JavaType type = mapper.getTypeFactory().constructType(InspectImageResponse.class);
168156

169-
final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_22,
170-
"images/docImage/inspect_doc.json",
171-
type
172-
);
157+
final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_22, "images/docImage/inspect_doc.json", type);
173158

174-
GraphData newGraphData = new GraphData()
175-
.withDeviceId("5")
176-
.withDeviceName("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47")
177-
.withDeviceSize("171798691840");
159+
GraphData newGraphData = new GraphData().withDeviceId("5")
160+
.withDeviceName("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47")
161+
.withDeviceSize("171798691840");
178162

179163
assertThat(inspectImage, notNullValue());
180164
GraphDriver graphDriver = inspectImage.getGraphDriver();
@@ -184,9 +168,24 @@ public void serder1_22_inspect_doc() throws IOException {
184168
assertThat(data, is(newGraphData));
185169

186170
assertThat(data.getDeviceId(), is("5"));
187-
assertThat(data.getDeviceName(),
188-
is("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47"));
189-
assertThat(data.getDeviceSize(),
190-
is("171798691840"));
171+
assertThat(data.getDeviceName(), is("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47"));
172+
assertThat(data.getDeviceSize(), is("171798691840"));
173+
}
174+
175+
@Test
176+
private void testOverlayNetworkRootDir() throws IOException {
177+
final ObjectMapper mapper = new ObjectMapper();
178+
final JavaType type = mapper.getTypeFactory().constructType(InspectImageResponse.class);
179+
180+
final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_22, "images/overlay/inspectOverlay.json", type);
181+
182+
final GraphData overlayGraphData = new GraphData().withRootDir("/var/lib/docker/overlay/7e8d362d6b78d47eafe4863fd129cbcada35dbd419d7188cc1dbf1233d505576/root");
183+
final GraphDriver overlayGraphDriver = new GraphDriver().withName("overlay").withData(overlayGraphData);
184+
final GraphDriver graphDriver = inspectImage.getGraphDriver();
185+
assertThat(graphDriver, notNullValue());
186+
assertThat(graphDriver, equalTo(overlayGraphDriver));
187+
assertThat(graphDriver.getName(), is("overlay"));
188+
assertThat(graphDriver.getData(), equalTo(overlayGraphData));
189+
191190
}
192191
}

0 commit comments

Comments
 (0)
X Tutup