Skip to content

Commit 9c81e41

Browse files
committed
Add OSVersion and RootFS support in InspectImageResponse
1 parent 153e06a commit 9c81e41

5 files changed

Lines changed: 250 additions & 0 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public class GraphData {
2828
@JsonProperty("DeviceSize")
2929
private String deviceSize;
3030

31+
@JsonProperty("dir")
32+
private String dir;
33+
3134
/**
3235
* @see #rootDir
3336
*/
@@ -92,6 +95,22 @@ public GraphData withDeviceSize(String deviceSize) {
9295
return this;
9396
}
9497

98+
/**
99+
* @see #dir
100+
*/
101+
@CheckForNull
102+
public String getDir() {
103+
return dir;
104+
}
105+
106+
/**
107+
* @see #dir
108+
*/
109+
public GraphData withDir(String dir) {
110+
this.dir = dir;
111+
return this;
112+
}
113+
95114
@Override
96115
public String toString() {
97116
return ToStringBuilder.reflectionToString(this);

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public class InspectImageResponse {
4949
@JsonProperty("Os")
5050
private String os;
5151

52+
/**
53+
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_25}
54+
*/
55+
@JsonProperty("OsVersion")
56+
private String osVersion;
57+
5258
@JsonProperty("Parent")
5359
private String parent;
5460

@@ -73,6 +79,9 @@ public class InspectImageResponse {
7379
@JsonProperty("GraphDriver")
7480
private GraphDriver graphDriver;
7581

82+
@JsonProperty("RootFS")
83+
private RootFS rootFS;
84+
7685
/**
7786
* @see #arch
7887
*/
@@ -236,6 +245,22 @@ public InspectImageResponse withOs(String os) {
236245
return this;
237246
}
238247

248+
/**
249+
* @see #osVersion
250+
*/
251+
@CheckForNull
252+
public String getOsVersion() {
253+
return osVersion;
254+
}
255+
256+
/**
257+
* @see #osVersion
258+
*/
259+
public InspectImageResponse withOsVersion(String osVersion) {
260+
this.osVersion = osVersion;
261+
return this;
262+
}
263+
239264
/**
240265
* @see #parent
241266
*/
@@ -332,6 +357,22 @@ public InspectImageResponse withVirtualSize(Long virtualSize) {
332357
return this;
333358
}
334359

360+
/**
361+
* @see #rootFS
362+
*/
363+
@CheckForNull
364+
public RootFS getRootFS() {
365+
return rootFS;
366+
}
367+
368+
/**
369+
* @see #rootFS
370+
*/
371+
public InspectImageResponse withRootFS(RootFS rootFS) {
372+
this.rootFS = rootFS;
373+
return this;
374+
}
375+
335376
@Override
336377
public String toString() {
337378
return ToStringBuilder.reflectionToString(this);
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import org.apache.commons.lang.builder.EqualsBuilder;
6+
import org.apache.commons.lang.builder.HashCodeBuilder;
7+
import org.apache.commons.lang.builder.ToStringBuilder;
8+
9+
import javax.annotation.CheckForNull;
10+
import java.util.List;
11+
12+
/**
13+
* Part of {@link InspectImageResponse}
14+
*
15+
* @author Dmitry Tretyakov
16+
*/
17+
@JsonIgnoreProperties(ignoreUnknown = true)
18+
public class RootFS {
19+
20+
@JsonProperty("Type")
21+
private String type;
22+
23+
@JsonProperty("Layers")
24+
private List<String> layers;
25+
26+
/**
27+
* @see #type
28+
*/
29+
@CheckForNull
30+
public String getType() {
31+
return type;
32+
}
33+
34+
/**
35+
* @see #type
36+
*/
37+
public RootFS withType(String type) {
38+
this.type = type;
39+
return this;
40+
}
41+
42+
/**
43+
* @see #layers
44+
*/
45+
@CheckForNull
46+
public List<String> getLayers() {
47+
return layers;
48+
}
49+
50+
/**
51+
* @see #layers
52+
*/
53+
public RootFS withLayers(List<String> layers) {
54+
this.layers = layers;
55+
return this;
56+
}
57+
58+
@Override
59+
public String toString() {
60+
return ToStringBuilder.reflectionToString(this);
61+
}
62+
63+
@Override
64+
public boolean equals(Object o) {
65+
return EqualsBuilder.reflectionEquals(this, o);
66+
}
67+
68+
@Override
69+
public int hashCode() {
70+
return HashCodeBuilder.reflectionHashCode(this);
71+
}
72+
}

src/test/java/com/github/dockerjava/api/command/InspectImageResponseTest.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.Collections;
1010

1111
import static com.github.dockerjava.core.RemoteApiVersion.VERSION_1_22;
12+
import static com.github.dockerjava.core.RemoteApiVersion.VERSION_1_25;
1213
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
1314
import static org.hamcrest.MatcherAssert.assertThat;
1415
import static org.hamcrest.Matchers.contains;
@@ -206,4 +207,49 @@ public void testOverlayNetworkRootDir() throws IOException {
206207
assertThat(graphDriver.getName(), is("overlay"));
207208
assertThat(graphDriver.getData(), equalTo(overlayGraphData));
208209
}
210+
211+
@Test
212+
public void inspectWindowsImage() throws IOException {
213+
final ObjectMapper mapper = new ObjectMapper();
214+
final JavaType type = mapper.getTypeFactory().constructType(InspectImageResponse.class);
215+
216+
final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_25,
217+
"images/windowsImage/doc.json",
218+
type
219+
);
220+
221+
assertThat(inspectImage, notNullValue());
222+
223+
assertThat(inspectImage.getRepoTags(), hasSize(1));
224+
assertThat(inspectImage.getRepoTags(), contains(
225+
"microsoft/nanoserver:latest"
226+
));
227+
228+
assertThat(inspectImage.getRepoDigests(), hasSize(1));
229+
assertThat(inspectImage.getRepoDigests(), contains("microsoft/nanoserver@" +
230+
"sha256:aee7d4330fe3dc5987c808f647441c16ed2fa1c7d9c6ef49d6498e5c9860b50b")
231+
);
232+
233+
assertThat(inspectImage.getConfig(), notNullValue());
234+
assertThat(inspectImage.getConfig().getCmd(), is(new String[]{"c:\\windows\\system32\\cmd.exe"}));
235+
236+
assertThat(inspectImage.getOs(), is("windows"));
237+
assertThat(inspectImage.getOsVersion(), is("10.0.14393"));
238+
assertThat(inspectImage.getSize(), is(651862727L));
239+
assertThat(inspectImage.getVirtualSize(), is(651862727L));
240+
241+
assertThat(inspectImage.getGraphDriver(), notNullValue());
242+
assertThat(inspectImage.getGraphDriver().getName(), is("windowsfilter"));
243+
assertThat(inspectImage.getGraphDriver().getData(), notNullValue());
244+
assertThat(inspectImage.getGraphDriver().getData().getDir(), is("C:\\control\\windowsfilter\\" +
245+
"6fe6a289b98276a6a5ca0345156ca61d7b38f3da6bb49ef95af1d0f1ac37e5bf"
246+
));
247+
248+
assertThat(inspectImage.getRootFS(), notNullValue());
249+
assertThat(inspectImage.getRootFS().getType(), is("layers"));
250+
assertThat(inspectImage.getRootFS().getLayers(), hasSize(1));
251+
assertThat(inspectImage.getRootFS().getLayers(), contains(
252+
"sha256:342d4e407550c52261edd20cd901b5ce438f0b1e940336de3978210612365063"
253+
));
254+
}
209255
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"Id": "sha256:105d76d0f40e38427c63023ffe649bf36fa85058d3469551e43e4dcc2431fb31",
3+
"RepoTags": [
4+
"microsoft/nanoserver:latest"
5+
],
6+
"RepoDigests": [
7+
"microsoft/nanoserver@sha256:aee7d4330fe3dc5987c808f647441c16ed2fa1c7d9c6ef49d6498e5c9860b50b"
8+
],
9+
"Parent": "",
10+
"Comment": "",
11+
"Created": "2016-09-22T02:39:30.9154862-07:00",
12+
"Container": "",
13+
"ContainerConfig": {
14+
"Hostname": "",
15+
"Domainname": "",
16+
"User": "",
17+
"AttachStdin": false,
18+
"AttachStdout": false,
19+
"AttachStderr": false,
20+
"Tty": false,
21+
"OpenStdin": false,
22+
"StdinOnce": false,
23+
"Env": null,
24+
"Cmd": null,
25+
"Image": "",
26+
"Volumes": null,
27+
"WorkingDir": "",
28+
"Entrypoint": null,
29+
"OnBuild": null,
30+
"Labels": null
31+
},
32+
"DockerVersion": "",
33+
"Author": "",
34+
"Config": {
35+
"Hostname": "",
36+
"Domainname": "",
37+
"User": "",
38+
"AttachStdin": false,
39+
"AttachStdout": false,
40+
"AttachStderr": false,
41+
"Tty": false,
42+
"OpenStdin": false,
43+
"StdinOnce": false,
44+
"Env": null,
45+
"Cmd": [
46+
"c:\\windows\\system32\\cmd.exe"
47+
],
48+
"Image": "",
49+
"Volumes": null,
50+
"WorkingDir": "",
51+
"Entrypoint": null,
52+
"OnBuild": null,
53+
"Labels": null
54+
},
55+
"Architecture": "",
56+
"Os": "windows",
57+
"OsVersion": "10.0.14393",
58+
"Size": 651862727,
59+
"VirtualSize": 651862727,
60+
"GraphDriver": {
61+
"Name": "windowsfilter",
62+
"Data": {
63+
"dir": "C:\\control\\windowsfilter\\6fe6a289b98276a6a5ca0345156ca61d7b38f3da6bb49ef95af1d0f1ac37e5bf"
64+
}
65+
},
66+
"RootFS": {
67+
"Type": "layers",
68+
"Layers": [
69+
"sha256:342d4e407550c52261edd20cd901b5ce438f0b1e940336de3978210612365063"
70+
]
71+
}
72+
}

0 commit comments

Comments
 (0)