forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadImageCallback.java
More file actions
49 lines (37 loc) · 1.34 KB
/
Copy pathLoadImageCallback.java
File metadata and controls
49 lines (37 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.github.dockerjava.api.command;
import com.github.dockerjava.api.async.ResultCallbackTemplate;
import com.github.dockerjava.api.exception.DockerClientException;
import com.github.dockerjava.api.model.LoadResponseItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoadImageCallback extends ResultCallbackTemplate<LoadImageCallback, LoadResponseItem> {
private static final Logger LOGGER = LoggerFactory.getLogger(LoadImageCallback.class);
private String message;
private String error;
@Override
public void onNext(LoadResponseItem item) {
if (item.isBuildSuccessIndicated()) {
this.message = item.getMessage();
} else if (item.isErrorIndicated()) {
this.error = item.getError();
}
LOGGER.debug(item.toString());
}
public String awaitMessage() {
try {
awaitCompletion();
} catch (InterruptedException e) {
throw new DockerClientException("", e);
}
return getMessage();
}
private String getMessage() {
if (this.message != null) {
return this.message;
}
if (this.error == null) {
throw new DockerClientException("Could not build image");
}
throw new DockerClientException("Could not build image: " + this.error);
}
}