File tree Expand file tree Collapse file tree 4 files changed +48
-5
lines changed
main/java/com/amihaiemil/docker
test/java/com/amihaiemil/docker Expand file tree Collapse file tree 4 files changed +48
-5
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ abstract class RtDocker implements Docker {
49
49
* Base URI.
50
50
*/
51
51
private final URI baseUri ;
52
-
52
+
53
53
/**
54
54
* Ctor.
55
55
* @param client Given HTTP Client.
@@ -59,7 +59,7 @@ abstract class RtDocker implements Docker {
59
59
this .client = client ;
60
60
this .baseUri = baseUri ;
61
61
}
62
-
62
+
63
63
@ Override
64
64
public final boolean ping () throws IOException {
65
65
final HttpGet ping = new HttpGet (this .baseUri .toString () + "/_ping" );
@@ -126,7 +126,7 @@ public final Execs execs() {
126
126
public final Swarm swarm () {
127
127
return new RtSwarm (
128
128
this .client ,
129
- URI .create (this .baseUri .toString ().concat ("/swarm" )),
129
+ URI .create (this .baseUri .toString ().concat ("/swarm" )),
130
130
this
131
131
);
132
132
}
@@ -157,7 +157,8 @@ public Version version() throws IOException {
157
157
final String versionUri = this .baseUri .toString () + "/version" ;
158
158
return new RtVersion (
159
159
this .client ,
160
- URI .create (versionUri )
160
+ URI .create (versionUri ),
161
+ this
161
162
);
162
163
}
163
164
Original file line number Diff line number Diff line change 39
39
* @since 0.0.11
40
40
*/
41
41
final class RtVersion extends JsonResource implements Version {
42
+
43
+ /**
44
+ * Docker to which this Version belongs.
45
+ */
46
+ private final Docker docker ;
47
+
42
48
/**
43
49
* Ctor.
44
50
* @param client The http client.
45
51
* @param uri The URI for this version.
52
+ * @param dkr Parent Docker.
46
53
* @throws IOException If an I/O error occurs.
47
54
*/
48
- RtVersion (final HttpClient client , final URI uri ) throws IOException {
55
+ RtVersion (
56
+ final HttpClient client ,
57
+ final URI uri ,
58
+ final Docker dkr
59
+ ) throws IOException {
49
60
super (fetch (client , uri ));
61
+ this .docker = dkr ;
50
62
}
51
63
52
64
/**
@@ -134,4 +146,9 @@ public String arch() {
134
146
public boolean experimental () {
135
147
return this .getBoolean ("Experimental" );
136
148
}
149
+
150
+ @ Override
151
+ public Docker docker () {
152
+ return this .docker ;
153
+ }
137
154
}
Original file line number Diff line number Diff line change @@ -49,4 +49,10 @@ public interface Version extends JsonObject {
49
49
* @return Whether experimental docker features are enabled
50
50
*/
51
51
boolean experimental ();
52
+
53
+ /**
54
+ * The Docker engine to which this Version belongs.
55
+ * @return Docker.
56
+ */
57
+ Docker docker ();
52
58
}
Original file line number Diff line number Diff line change @@ -80,6 +80,25 @@ public void returnsInfo() throws Exception {
80
80
);
81
81
}
82
82
83
+ /**
84
+ * UnixDocker can return the Version of Docker.
85
+ * @throws Exception If something goes wrong.
86
+ */
87
+ @ Test
88
+ public void returnsVersion () throws Exception {
89
+ final Docker docker = new UnixDocker (
90
+ new File ("/var/run/docker.sock" )
91
+ );
92
+ final Version version = docker .version ();
93
+ MatcherAssert .assertThat (version , Matchers .notNullValue ());
94
+ MatcherAssert .assertThat (version .docker (), Matchers .is (docker ));
95
+ MatcherAssert .assertThat (
96
+ version .platformName (),
97
+ Matchers .equalTo ("Docker Engine - Community" )
98
+ );
99
+ }
100
+
101
+
83
102
/**
84
103
* Docker can return its Events unfiltered.
85
104
* @throws Exception If something goes wrong.
You can’t perform that action at this time.
0 commit comments