Skip to content

Commit 3bb58c1

Browse files
martin894KostyaSha
authored andcommitted
Add endpoints for Swarm in swarm mode
Apply changes from review Remove unused import Fix compile errors
1 parent 0f3d479 commit 3bb58c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3482
-59
lines changed

src/main/java/com/github/dockerjava/api/DockerClient.java

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
package com.github.dockerjava.api;
22

3-
import java.io.Closeable;
4-
import java.io.File;
5-
import java.io.IOException;
6-
import java.io.InputStream;
7-
8-
import javax.annotation.Nonnull;
9-
103
import com.github.dockerjava.api.command.AttachContainerCmd;
114
import com.github.dockerjava.api.command.AuthCmd;
125
import com.github.dockerjava.api.command.BuildImageCmd;
@@ -25,12 +18,16 @@
2518
import com.github.dockerjava.api.command.ExecCreateCmd;
2619
import com.github.dockerjava.api.command.ExecStartCmd;
2720
import com.github.dockerjava.api.command.InfoCmd;
21+
import com.github.dockerjava.api.command.InitializeSwarmCmd;
2822
import com.github.dockerjava.api.command.InspectContainerCmd;
2923
import com.github.dockerjava.api.command.InspectExecCmd;
3024
import com.github.dockerjava.api.command.InspectImageCmd;
3125
import com.github.dockerjava.api.command.InspectNetworkCmd;
26+
import com.github.dockerjava.api.command.InspectSwarmCmd;
3227
import com.github.dockerjava.api.command.InspectVolumeCmd;
28+
import com.github.dockerjava.api.command.JoinSwarmCmd;
3329
import com.github.dockerjava.api.command.KillContainerCmd;
30+
import com.github.dockerjava.api.command.LeaveSwarmCmd;
3431
import com.github.dockerjava.api.command.ListContainersCmd;
3532
import com.github.dockerjava.api.command.ListImagesCmd;
3633
import com.github.dockerjava.api.command.ListNetworksCmd;
@@ -45,6 +42,7 @@
4542
import com.github.dockerjava.api.command.RemoveImageCmd;
4643
import com.github.dockerjava.api.command.RemoveNetworkCmd;
4744
import com.github.dockerjava.api.command.RemoveVolumeCmd;
45+
import com.github.dockerjava.api.command.RenameContainerCmd;
4846
import com.github.dockerjava.api.command.RestartContainerCmd;
4947
import com.github.dockerjava.api.command.SaveImageCmd;
5048
import com.github.dockerjava.api.command.SearchImagesCmd;
@@ -55,14 +53,21 @@
5553
import com.github.dockerjava.api.command.TopContainerCmd;
5654
import com.github.dockerjava.api.command.UnpauseContainerCmd;
5755
import com.github.dockerjava.api.command.UpdateContainerCmd;
56+
import com.github.dockerjava.api.command.UpdateSwarmCmd;
5857
import com.github.dockerjava.api.command.VersionCmd;
5958
import com.github.dockerjava.api.command.WaitContainerCmd;
60-
import com.github.dockerjava.api.command.RenameContainerCmd;
6159
import com.github.dockerjava.api.exception.DockerException;
6260
import com.github.dockerjava.api.model.AuthConfig;
6361
import com.github.dockerjava.api.model.Identifier;
62+
import com.github.dockerjava.api.model.SwarmSpec;
6463
import com.github.dockerjava.core.RemoteApiVersion;
6564

65+
import javax.annotation.Nonnull;
66+
import java.io.Closeable;
67+
import java.io.File;
68+
import java.io.IOException;
69+
import java.io.InputStream;
70+
6671
// https://godoc.org/github.com/fsouza/go-dockerclient
6772
public interface DockerClient extends Closeable {
6873

@@ -255,6 +260,48 @@ public interface DockerClient extends Closeable {
255260

256261
DisconnectFromNetworkCmd disconnectFromNetworkCmd();
257262

263+
/**
264+
* Enables swarm mode for the docker engine and creates a new swarm cluster
265+
*
266+
* @since 1.24
267+
* @param swarmSpec the specification for the swarm
268+
* @return the command
269+
*/
270+
InitializeSwarmCmd initializeSwarmCmd(SwarmSpec swarmSpec);
271+
272+
/**
273+
* Gets information about the swarm the docker engine is currently in
274+
*
275+
* @since 1.24
276+
* @return the command
277+
*/
278+
InspectSwarmCmd inspectSwarmCmd();
279+
280+
/**
281+
* Enables swarm mode for the docker engine and joins an existing swarm cluster
282+
*
283+
* @since 1.24
284+
* @return the command
285+
*/
286+
JoinSwarmCmd joinSwarmCmd();
287+
288+
/**
289+
* Disables swarm node for the docker engine and leaves the swarm cluster
290+
*
291+
* @since 1.24
292+
* @return the command
293+
*/
294+
LeaveSwarmCmd leaveSwarmCmd();
295+
296+
/**
297+
* Updates the swarm specification
298+
*
299+
* @since 1.24
300+
* @param swarmSpec the specification for the swarm
301+
* @return the command
302+
*/
303+
UpdateSwarmCmd updateSwarmCmd(SwarmSpec swarmSpec);
304+
258305
@Override
259306
void close() throws IOException;
260307

src/main/java/com/github/dockerjava/api/command/DockerCmdExecFactory.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,16 @@ public interface DockerCmdExecFactory extends Closeable {
117117

118118
DisconnectFromNetworkCmd.Exec createDisconnectFromNetworkCmdExec();
119119

120+
InitializeSwarmCmd.Exec createInitializeSwarmCmdExec();
121+
122+
InspectSwarmCmd.Exec createInspectSwarmCmdExec();
123+
124+
JoinSwarmCmd.Exec createJoinSwarmCmdExec();
125+
126+
LeaveSwarmCmd.Exec createLeaveSwarmCmdExec();
127+
128+
UpdateSwarmCmd.Exec createUpdateSwarmCmdExec();
129+
120130
@Override
121131
void close() throws IOException;
122-
123132
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.github.dockerjava.api.command;
2+
3+
4+
import com.github.dockerjava.api.model.SwarmSpec;
5+
6+
import javax.annotation.CheckForNull;
7+
8+
public interface InitializeSwarmCmd extends SyncDockerCmd<Void> {
9+
10+
@CheckForNull
11+
String getListenAddr();
12+
13+
InitializeSwarmCmd withListenAddr(String listenAddr);
14+
15+
@CheckForNull
16+
String getAdvertiseAddr();
17+
18+
InitializeSwarmCmd withAdvertiseAddr(String advertiseAddr);
19+
20+
@CheckForNull
21+
Boolean isForceNewCluster();
22+
23+
InitializeSwarmCmd withForceNewCluster(Boolean forceNewCluster);
24+
25+
@CheckForNull
26+
SwarmSpec getSwarmSpec();
27+
28+
InitializeSwarmCmd withSwarmSpec(SwarmSpec swarmSpec);
29+
30+
@Override
31+
Void exec();
32+
33+
interface Exec extends DockerCmdSyncExec<InitializeSwarmCmd, Void> {
34+
35+
}
36+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.github.dockerjava.api.command;
2+
3+
4+
import com.github.dockerjava.api.model.Swarm;
5+
6+
/**
7+
* Inspect a swarm.
8+
*/
9+
public interface InspectSwarmCmd extends SyncDockerCmd<Swarm> {
10+
11+
@Override
12+
Swarm exec();
13+
14+
interface Exec extends DockerCmdSyncExec<InspectSwarmCmd, Swarm> {
15+
}
16+
17+
18+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.github.dockerjava.api.command;
2+
3+
4+
import javax.annotation.CheckForNull;
5+
import java.util.List;
6+
7+
public interface JoinSwarmCmd extends SyncDockerCmd<Void> {
8+
9+
@CheckForNull
10+
String getListenAddr();
11+
12+
JoinSwarmCmd withListenAddr(String listenAddr);
13+
14+
@CheckForNull
15+
String getAdvertiseAddr();
16+
17+
JoinSwarmCmd withAdvertiseAddr(String advertiseAddr);
18+
19+
@CheckForNull
20+
List<String> getRemoteAddrs();
21+
22+
JoinSwarmCmd withRemoteAddrs(List<String> remoteAddrs);
23+
24+
@CheckForNull
25+
String getJoinToken();
26+
27+
JoinSwarmCmd withJoinToken(String joinToken);
28+
29+
@Override
30+
Void exec();
31+
32+
interface Exec extends DockerCmdSyncExec<JoinSwarmCmd, Void> {
33+
}
34+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.github.dockerjava.api.command;
2+
3+
4+
import javax.annotation.CheckForNull;
5+
6+
public interface LeaveSwarmCmd extends SyncDockerCmd<Void> {
7+
8+
@CheckForNull
9+
Boolean hasForceEnabled();
10+
11+
LeaveSwarmCmd withForceEnabled(Boolean force);
12+
13+
@Override
14+
Void exec();
15+
16+
interface Exec extends DockerCmdSyncExec<LeaveSwarmCmd, Void> {
17+
}
18+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.github.dockerjava.api.command;
2+
3+
4+
import com.github.dockerjava.api.model.SwarmSpec;
5+
6+
import javax.annotation.CheckForNull;
7+
8+
public interface UpdateSwarmCmd extends SyncDockerCmd<Void> {
9+
10+
@CheckForNull
11+
Long getVersion();
12+
13+
UpdateSwarmCmd withVersion(Long version);
14+
15+
@CheckForNull
16+
Boolean getRotateWorkerToken();
17+
18+
UpdateSwarmCmd withRotateWorkerToken(Boolean rotateWorkerToken);
19+
20+
@CheckForNull
21+
Boolean getRotateManagerToken();
22+
23+
UpdateSwarmCmd withRotateManagerToken(Boolean rotateManagerToken);
24+
25+
@CheckForNull
26+
SwarmSpec getSwarmSpec();
27+
28+
UpdateSwarmCmd withSwarmSpec(SwarmSpec swarmSpec);
29+
30+
@Override
31+
Void exec();
32+
33+
interface Exec extends DockerCmdSyncExec<UpdateSwarmCmd, Void> {
34+
}
35+
}

0 commit comments

Comments
 (0)