Skip to content
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
86 changes: 86 additions & 0 deletions src/main/java/com/github/dockerjava/api/command/GraphData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.github.dockerjava.api.command;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import javax.annotation.CheckForNull;

/**
* part of {@link GraphDriver}
* @author Kanstantsin Shautsou
*/
public class GraphData {
@JsonProperty("DeviceId")
private String deviceId;

@JsonProperty("DeviceName")
private String deviceName;

@JsonProperty("DeviceSize")
private String deviceSize;

/**
* @see #deviceId
*/
@CheckForNull
public String getDeviceId() {
return deviceId;
}

/**
* @see #deviceId
*/
public GraphData withDeviceId(String deviceId) {
this.deviceId = deviceId;
return this;
}

/**
* @see #deviceName
*/
@CheckForNull
public String getDeviceName() {
return deviceName;
}

/**
* @see #deviceName
*/
public GraphData withDeviceName(String deviceName) {
this.deviceName = deviceName;
return this;
}

/**
* @see #deviceSize
*/
@CheckForNull
public String getDeviceSize() {
return deviceSize;
}

/**
* @see #deviceSize
*/
public GraphData withDeviceSize(String deviceSize) {
this.deviceSize = deviceSize;
return this;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}

@Override
public boolean equals(Object o) {
return EqualsBuilder.reflectionEquals(this, o);
}

@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ public class GraphDriver {
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_21}
*/
@JsonProperty("Data")
private String data;
private GraphData data;


/**
* @see #data
*/
@CheckForNull
public String getData() {
public GraphData getData() {
return data;
}

/**
* @see #data
*/
public GraphDriver withData(String data) {
public GraphDriver withData(GraphData data) {
this.data = data;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,33 @@ public void serder1_22_doc() throws IOException {
"example:stable"
));
}

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

final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_22,
"images/docImage/inspect_doc.json",
type
);

GraphData newGraphData = new GraphData()
.withDeviceId("5")
.withDeviceName("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47")
.withDeviceSize("171798691840");

assertThat(inspectImage, notNullValue());
GraphDriver graphDriver = inspectImage.getGraphDriver();
assertThat(graphDriver, notNullValue());
GraphData data = graphDriver.getData();

assertThat(data, is(newGraphData));

assertThat(data.getDeviceId(), is("5"));
assertThat(data.getDeviceName(),
is("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47"));
assertThat(data.getDeviceSize(),
is("171798691840"));
}
}
150 changes: 150 additions & 0 deletions src/test/resources/samples/1.22/images/docImage/inspect_doc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"Id": "d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47",
"Created": "2015-06-08T16:18:02.505155285Z",
"Path": "bash",
"Args": [],
"State": {
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 0,
"Error": "",
"StartedAt": "2015-06-08T16:18:03.643865954Z",
"FinishedAt": "2015-06-08T16:57:06.448552862Z"
},
"Image": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4",
"NetworkSettings": {
"Bridge": "",
"SandboxID": "6b4851d1903e16dd6a567bd526553a86664361f31036eaaa2f8454d6f4611f6f",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/6b4851d1903e",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:12:00:02",
"Networks": {
"bridge": {
"NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
"EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02"
}
}
},
"ResolvConfPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hostname",
"HostsPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hosts",
"LogPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47-json.log",
"Name": "/adoring_wozniak",
"RestartCount": 0,
"Driver": "devicemapper",
"MountLabel": "",
"ProcessLabel": "",
"Mounts": [
{
"Source": "/data",
"Destination": "/data",
"Mode": "ro,Z",
"RW": false,
"Propagation": ""
}
],
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"Memory": 0,
"MemorySwap": 0,
"CpuShares": 0,
"CpuPeriod": 0,
"CpusetCpus": "",
"CpusetMems": "",
"CpuQuota": 0,
"BlkioWeight": 0,
"OomKillDisable": false,
"Privileged": false,
"PortBindings": {},
"Links": null,
"PublishAllPorts": false,
"Dns": null,
"DnsSearch": null,
"DnsOptions": null,
"ExtraHosts": null,
"VolumesFrom": null,
"Devices": [],
"NetworkMode": "bridge",
"IpcMode": "",
"PidMode": "",
"UTSMode": "",
"CapAdd": null,
"CapDrop": null,
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"SecurityOpt": null,
"ReadonlyRootfs": false,
"Ulimits": null,
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"CgroupParent": ""
},
"GraphDriver": {
"Name": "devicemapper",
"Data": {
"DeviceId": "5",
"DeviceName": "docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47",
"DeviceSize": "171798691840"
}
},
"Config": {
"Hostname": "d2cc496561d6",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": null,
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": null,
"Cmd": [
"bash"
],
"Image": "fedora",
"Volumes": null,
"VolumeDriver": "",
"WorkingDir": "",
"Entrypoint": null,
"NetworkDisabled": false,
"MacAddress": "",
"OnBuild": null,
"Labels": {},
"Memory": 0,
"MemorySwap": 0,
"CpuShares": 0,
"Cpuset": "",
"StopSignal": "SIGTERM"
}
}