Skip to content

Commit ecef825

Browse files
committed
Add missing properties in InspectContainer response
1 parent 9cd0492 commit ecef825

File tree

5 files changed

+273
-1
lines changed

5 files changed

+273
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import javax.annotation.CheckForNull;
1111

1212
/**
13-
* Part of {@link InspectImageResponse}
13+
* Part of {@link InspectImageResponse} and {@link InspectContainerResponse}
1414
*
1515
* @author Kanstantsin Shautsou
1616
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_21}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ public class InspectContainerResponse {
110110
@JsonProperty("Mounts")
111111
private List<Mount> mounts;
112112

113+
@JsonProperty("GraphDriver")
114+
private GraphDriver graphDriver;
115+
116+
/**
117+
* @since {@link RemoteApiVersion#VERSION_1_30}
118+
*/
119+
@JsonProperty("Platform")
120+
private String platform;
121+
113122
public String getId() {
114123
return id;
115124
}
@@ -227,6 +236,22 @@ public Node getNode() {
227236
return node;
228237
}
229238

239+
/**
240+
* @see #graphDriver
241+
*/
242+
@CheckForNull
243+
public GraphDriver getGraphDriver() {
244+
return graphDriver;
245+
}
246+
247+
/**
248+
* @see #platform
249+
*/
250+
@CheckForNull
251+
public String getPlatform() {
252+
return platform;
253+
}
254+
230255
@Override
231256
public String toString() {
232257
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);

src/main/java/com/github/dockerjava/api/model/HostConfig.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ public class HostConfig implements Serializable {
225225
@JsonProperty("Tmpfs")
226226
private Map<String, String> tmpFs;
227227

228+
/**
229+
* @since ~{@link RemoteApiVersion#VERSION_1_22}
230+
*/
231+
@JsonProperty("Isolation")
232+
private String isolation;
233+
228234
@JsonIgnore
229235
public Bind[] getBinds() {
230236
return (binds == null) ? new Bind[0] : binds.getBinds();
@@ -329,6 +335,14 @@ public String getPidMode() {
329335
return pidMode;
330336
}
331337

338+
/**
339+
* @see #isolation
340+
*/
341+
@CheckForNull
342+
public String getIsolation() {
343+
return isolation;
344+
}
345+
332346
/**
333347
* @see #blkioDeviceReadBps
334348
*/
@@ -892,6 +906,14 @@ public HostConfig withTmpFs(Map<String, String> tmpFs) {
892906
return this;
893907
}
894908

909+
/**
910+
* @see #isolation
911+
*/
912+
public HostConfig withIsolation(String isolation) {
913+
this.isolation = isolation;
914+
return this;
915+
}
916+
895917
// end of auto-generated
896918

897919
@Override

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717

1818
import com.fasterxml.jackson.databind.JavaType;
1919
import com.fasterxml.jackson.databind.ObjectMapper;
20+
import com.github.dockerjava.api.model.ContainerNetwork;
2021
import com.github.dockerjava.api.model.Volume;
2122
import com.github.dockerjava.core.RemoteApiVersion;
2223
import org.junit.Test;
2324

2425
import java.io.IOException;
26+
import java.util.Collections;
2527
import java.util.List;
2628

2729
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
@@ -30,6 +32,7 @@
3032
import static org.hamcrest.Matchers.containsString;
3133
import static org.hamcrest.Matchers.is;
3234
import static org.hamcrest.Matchers.isEmptyString;
35+
import static org.hamcrest.Matchers.notNullValue;
3336
import static org.hamcrest.Matchers.nullValue;
3437
import static org.hamcrest.core.IsNot.not;
3538
import static org.junit.Assert.assertEquals;
@@ -131,4 +134,57 @@ public void roundTrip_1_26b_full() throws IOException {
131134
public void roundTrip_empty() throws IOException {
132135
testRoundTrip(CommandJSONSamples.inspectContainerResponse_empty, InspectContainerResponse[].class);
133136
}
137+
138+
@Test
139+
public void inspect_windows_container() throws IOException {
140+
141+
final ObjectMapper mapper = new ObjectMapper();
142+
final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(InspectContainerResponse.class);
143+
144+
final InspectContainerResponse response = testRoundTrip(RemoteApiVersion.VERSION_1_38,
145+
"/containers/inspect/lcow.json",
146+
type
147+
);
148+
149+
assertThat(response, notNullValue());
150+
151+
assertThat(response.getConfig(), notNullValue());
152+
assertThat(response.getConfig().getCmd(), is(new String[]{"cmd"}));
153+
assertThat(response.getConfig().getImage(), is("microsoft/nanoserver"));
154+
155+
assertThat(response.getDriver(), is("windowsfilter"));
156+
157+
assertThat(response.getGraphDriver(), notNullValue());
158+
assertThat(response.getGraphDriver().getName(), is("windowsfilter"));
159+
assertThat(response.getGraphDriver().getData(), is(new GraphData().withDir(
160+
"C:\\ProgramData\\Docker\\windowsfilter\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556"
161+
)));
162+
163+
assertThat(response.getHostConfig(), notNullValue());
164+
assertThat(response.getHostConfig().getIsolation(), is("hyperv"));
165+
166+
assertThat(response.getImageId(), is("sha256:1381511ec0122f197b6abff5bc0692bef19943ddafd6680eff41197afa3a6dda"));
167+
assertThat(response.getLogPath(), is(
168+
"C:\\ProgramData\\Docker\\containers\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556" +
169+
"\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556-json.log"
170+
));
171+
assertThat(response.getName(), is("/cranky_clarke"));
172+
173+
assertThat(response.getNetworkSettings(), notNullValue());
174+
assertThat(response.getNetworkSettings().getNetworks(), is(Collections.singletonMap("nat",
175+
new ContainerNetwork()
176+
.withEndpointId("493b77d6fe7e3b92435b1eb01461fde669781330deb84a9cbada360db8997ebc")
177+
.withGateway("172.17.18.1")
178+
.withGlobalIPv6Address("")
179+
.withGlobalIPv6PrefixLen(0)
180+
.withIpv4Address("172.17.18.123")
181+
.withIpPrefixLen(16)
182+
.withIpV6Gateway("")
183+
.withMacAddress("00:aa:ff:cf:dd:09")
184+
.withNetworkID("398c0e206dd677ed4a6566f9de458311f5767d8c7a8b963275490ab64c5d10a7")
185+
)));
186+
187+
assertThat(response.getPath(), is("cmd"));
188+
assertThat(response.getPlatform(), is("windows"));
189+
}
134190
}
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
{
2+
"AppArmorProfile": "",
3+
"Args": [],
4+
"Config": {
5+
"AttachStderr": true,
6+
"AttachStdin": true,
7+
"AttachStdout": true,
8+
"Cmd": [
9+
"cmd"
10+
],
11+
"Domainname": "",
12+
"Entrypoint": null,
13+
"Env": null,
14+
"Hostname": "35da02ca897b",
15+
"Image": "microsoft/nanoserver",
16+
"Labels": {},
17+
"OnBuild": null,
18+
"OpenStdin": true,
19+
"StdinOnce": true,
20+
"Tty": true,
21+
"User": "",
22+
"Volumes": null,
23+
"WorkingDir": ""
24+
},
25+
"Created": "2018-09-18T10:37:25.0470753Z",
26+
"Driver": "windowsfilter",
27+
"ExecIDs": null,
28+
"GraphDriver": {
29+
"Data": {
30+
"dir": "C:\\ProgramData\\Docker\\windowsfilter\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556"
31+
},
32+
"Name": "windowsfilter"
33+
},
34+
"HostConfig": {
35+
"AutoRemove": true,
36+
"Binds": null,
37+
"BlkioDeviceReadBps": null,
38+
"BlkioDeviceReadIOps": null,
39+
"BlkioDeviceWriteBps": null,
40+
"BlkioDeviceWriteIOps": null,
41+
"BlkioWeight": 0,
42+
"BlkioWeightDevice": [],
43+
"CapAdd": null,
44+
"CapDrop": null,
45+
"Cgroup": "",
46+
"CgroupParent": "",
47+
"ConsoleSize": [
48+
50,
49+
173
50+
],
51+
"ContainerIDFile": "",
52+
"CpuCount": 0,
53+
"CpuPercent": 0,
54+
"CpuPeriod": 0,
55+
"CpuQuota": 0,
56+
"CpuRealtimePeriod": 0,
57+
"CpuRealtimeRuntime": 0,
58+
"CpuShares": 0,
59+
"CpusetCpus": "",
60+
"CpusetMems": "",
61+
"DeviceCgroupRules": null,
62+
"Devices": [],
63+
"DiskQuota": 0,
64+
"Dns": [],
65+
"DnsOptions": [],
66+
"DnsSearch": [],
67+
"ExtraHosts": null,
68+
"GroupAdd": null,
69+
"IOMaximumBandwidth": 0,
70+
"IOMaximumIOps": 0,
71+
"IpcMode": "",
72+
"Isolation": "hyperv",
73+
"KernelMemory": 0,
74+
"Links": null,
75+
"LogConfig": {
76+
"Config": {},
77+
"Type": "json-file"
78+
},
79+
"MaskedPaths": null,
80+
"Memory": 0,
81+
"MemoryReservation": 0,
82+
"MemorySwap": 0,
83+
"MemorySwappiness": null,
84+
"NanoCpus": 0,
85+
"NetworkMode": "default",
86+
"OomKillDisable": false,
87+
"OomScoreAdj": 0,
88+
"PidMode": "",
89+
"PidsLimit": 0,
90+
"PortBindings": {},
91+
"Privileged": false,
92+
"PublishAllPorts": false,
93+
"ReadonlyPaths": null,
94+
"ReadonlyRootfs": false,
95+
"RestartPolicy": {
96+
"MaximumRetryCount": 0,
97+
"Name": "no"
98+
},
99+
"SecurityOpt": null,
100+
"ShmSize": 0,
101+
"UTSMode": "",
102+
"Ulimits": null,
103+
"UsernsMode": "",
104+
"VolumeDriver": "",
105+
"VolumesFrom": null
106+
},
107+
"HostnamePath": "",
108+
"HostsPath": "",
109+
"Id": "35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556",
110+
"Image": "sha256:1381511ec0122f197b6abff5bc0692bef19943ddafd6680eff41197afa3a6dda",
111+
"LogPath": "C:\\ProgramData\\Docker\\containers\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556-json.log",
112+
"MountLabel": "",
113+
"Mounts": [],
114+
"Name": "/cranky_clarke",
115+
"NetworkSettings": {
116+
"Bridge": "",
117+
"EndpointID": "",
118+
"Gateway": "",
119+
"GlobalIPv6Address": "",
120+
"GlobalIPv6PrefixLen": 0,
121+
"HairpinMode": false,
122+
"IPAddress": "",
123+
"IPPrefixLen": 0,
124+
"IPv6Gateway": "",
125+
"LinkLocalIPv6Address": "",
126+
"LinkLocalIPv6PrefixLen": 0,
127+
"MacAddress": "",
128+
"Networks": {
129+
"nat": {
130+
"Aliases": null,
131+
"DriverOpts": null,
132+
"EndpointID": "493b77d6fe7e3b92435b1eb01461fde669781330deb84a9cbada360db8997ebc",
133+
"Gateway": "172.17.18.1",
134+
"GlobalIPv6Address": "",
135+
"GlobalIPv6PrefixLen": 0,
136+
"IPAMConfig": null,
137+
"IPAddress": "172.17.18.123",
138+
"IPPrefixLen": 16,
139+
"IPv6Gateway": "",
140+
"Links": null,
141+
"MacAddress": "00:aa:ff:cf:dd:09",
142+
"NetworkID": "398c0e206dd677ed4a6566f9de458311f5767d8c7a8b963275490ab64c5d10a7"
143+
}
144+
},
145+
"Ports": {},
146+
"SandboxID": "35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556",
147+
"SandboxKey": "35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556",
148+
"SecondaryIPAddresses": null,
149+
"SecondaryIPv6Addresses": null
150+
},
151+
"Path": "cmd",
152+
"Platform": "windows",
153+
"ProcessLabel": "",
154+
"ResolvConfPath": "",
155+
"RestartCount": 0,
156+
"State": {
157+
"Dead": false,
158+
"Error": "",
159+
"ExitCode": 0,
160+
"FinishedAt": "0001-01-01T00:00:00Z",
161+
"OOMKilled": false,
162+
"Paused": false,
163+
"Pid": 1588,
164+
"Restarting": false,
165+
"Running": true,
166+
"StartedAt": "2018-09-18T10:37:28.3668368Z",
167+
"Status": "running"
168+
}
169+
}

0 commit comments

Comments
 (0)