Skip to content

Commit f51447f

Browse files
martin894Yogu
authored andcommitted
Add endpoints for Swarm in swarm mode
1 parent 8c456c2 commit f51447f

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

+3457
-57
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

@@ -251,6 +256,48 @@ public interface DockerClient extends Closeable {
251256

252257
DisconnectFromNetworkCmd disconnectFromNetworkCmd();
253258

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

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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.github.dockerjava.api.command;
2+
3+
4+
import javax.annotation.CheckForNull;
5+
6+
public interface JoinSwarmCmd extends SyncDockerCmd<Void> {
7+
8+
@CheckForNull
9+
String getListenAddr();
10+
11+
JoinSwarmCmd withListenAddr(String listenAddr);
12+
13+
@CheckForNull
14+
String getAdvertiseAddr();
15+
16+
JoinSwarmCmd withAdvertiseAddr(String advertiseAddr);
17+
18+
@CheckForNull
19+
String[] getRemoteAddrs();
20+
21+
JoinSwarmCmd withRemoteAddrs(String[] remoteAddrs);
22+
23+
@CheckForNull
24+
String getJoinToken();
25+
26+
JoinSwarmCmd withJoinToken(String joinToken);
27+
28+
@Override
29+
Void exec();
30+
31+
interface Exec extends DockerCmdSyncExec<JoinSwarmCmd, Void> {
32+
}
33+
}
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)