forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPushImageCmd.java
More file actions
78 lines (62 loc) · 2.2 KB
/
Copy pathPushImageCmd.java
File metadata and controls
78 lines (62 loc) · 2.2 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.github.dockerjava.api.command;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.exception.DockerClientException;
import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.AuthConfig;
import com.github.dockerjava.api.model.PushResponseItem;
/**
* Push the latest image to the repository.
*
* @param name
* The name, e.g. "alexec/busybox" or just "busybox" if you want to default. Not null.
*/
public interface PushImageCmd extends AsyncDockerCmd<PushImageCmd, PushResponseItem> {
@CheckForNull
AuthConfig getAuthConfig();
@CheckForNull
String getName();
@CheckForNull
String getTag();
/**
* @param name
* The name, e.g. "alexec/busybox" or just "busybox" if you want to default. Not null.
*/
PushImageCmd withName(@Nonnull String name);
/**
* @param tag
* The image's tag. Not null.
*/
PushImageCmd withTag(String tag);
PushImageCmd withAuthConfig(AuthConfig authConfig);
/**
* @throws NotFoundException
* No such image
*/
@Override
<T extends ResultCallback<PushResponseItem>> T exec(T resultCallback);
@Override
default ResultCallback.Adapter<PushResponseItem> start() {
return exec(new ResultCallback.Adapter<PushResponseItem>() {
@Nullable
private PushResponseItem latestItem = null;
@Override
public void onNext(PushResponseItem item) {
this.latestItem = item;
}
@Override
protected void throwFirstError() {
super.throwFirstError();
if (latestItem == null) {
throw new DockerClientException("Could not push image");
} else if (latestItem.isErrorIndicated()) {
throw new DockerClientException("Could not push image: " + latestItem.getError());
}
}
});
}
interface Exec extends DockerCmdAsyncExec<PushImageCmd, PushResponseItem> {
}
}