|
33 | 33 | import java.util.HashMap;
|
34 | 34 | import java.util.List;
|
35 | 35 | import java.util.Map;
|
| 36 | +import java.util.Objects; |
36 | 37 | import java.util.stream.Collectors;
|
37 | 38 |
|
38 | 39 | import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
@@ -121,16 +122,16 @@ private JsonStream jsonStream() {
|
121 | 122 | return this.jsonStream;
|
122 | 123 | }
|
123 | 124 |
|
124 |
| - private URI buildUrl(String path, Collection<String> params) { |
125 |
| - return buildUrl(path, StringUtils.toStringArray(params)); |
| 125 | + private URI buildUrl(String path, Collection<?> params) { |
| 126 | + return buildUrl(path, (params != null) ? params.toArray() : null); |
126 | 127 | }
|
127 | 128 |
|
128 |
| - private URI buildUrl(String path, String... params) { |
| 129 | + private URI buildUrl(String path, Object... params) { |
129 | 130 | try {
|
130 | 131 | URIBuilder builder = new URIBuilder("/" + API_VERSION + path);
|
131 | 132 | int param = 0;
|
132 | 133 | while (param < params.length) {
|
133 |
| - builder.addParameter(params[param++], params[param++]); |
| 134 | + builder.addParameter(Objects.toString(params[param++]), Objects.toString(params[param++])); |
134 | 135 | }
|
135 | 136 | return builder.build();
|
136 | 137 | }
|
@@ -190,7 +191,7 @@ public Image pull(ImageReference reference, UpdateListener<PullImageUpdateEvent>
|
190 | 191 | throws IOException {
|
191 | 192 | Assert.notNull(reference, "Reference must not be null");
|
192 | 193 | Assert.notNull(listener, "Listener must not be null");
|
193 |
| - URI createUri = buildUrl("/images/create", "fromImage", reference.toString()); |
| 194 | + URI createUri = buildUrl("/images/create", "fromImage", reference); |
194 | 195 | DigestCaptureUpdateListener digestCapture = new DigestCaptureUpdateListener();
|
195 | 196 | listener.onStart();
|
196 | 197 | try {
|
@@ -348,14 +349,9 @@ public void tag(ImageReference sourceReference, ImageReference targetReference)
|
348 | 349 | Assert.notNull(sourceReference, "SourceReference must not be null");
|
349 | 350 | Assert.notNull(targetReference, "TargetReference must not be null");
|
350 | 351 | String tag = targetReference.getTag();
|
351 |
| - URI uri; |
352 |
| - if (tag == null) { |
353 |
| - uri = buildUrl("/images/" + sourceReference + "/tag", "repo", targetReference.toString()); |
354 |
| - } |
355 |
| - else { |
356 |
| - uri = buildUrl("/images/" + sourceReference + "/tag", "repo", |
357 |
| - targetReference.inTaglessForm().toString(), "tag", tag); |
358 |
| - } |
| 352 | + String path = "/images/" + sourceReference + "/tag"; |
| 353 | + URI uri = (tag != null) ? buildUrl(path, "repo", targetReference.inTaglessForm(), "tag", tag) |
| 354 | + : buildUrl(path, "repo", targetReference); |
359 | 355 | http().post(uri).close();
|
360 | 356 | }
|
361 | 357 |
|
@@ -437,7 +433,7 @@ public void start(ContainerReference reference) throws IOException {
|
437 | 433 | public void logs(ContainerReference reference, UpdateListener<LogUpdateEvent> listener) throws IOException {
|
438 | 434 | Assert.notNull(reference, "Reference must not be null");
|
439 | 435 | Assert.notNull(listener, "Listener must not be null");
|
440 |
| - String[] params = { "stdout", "1", "stderr", "1", "follow", "1" }; |
| 436 | + Object[] params = { "stdout", "1", "stderr", "1", "follow", "1" }; |
441 | 437 | URI uri = buildUrl("/containers/" + reference + "/logs", params);
|
442 | 438 | listener.onStart();
|
443 | 439 | try {
|
|
0 commit comments