-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHE-253: Refactor Che docker client to be able to add new parameters …
…without breaking code dependent on docker client Signed-off-by: Mykola Morhun <mmorhun@codenvy.com>
- Loading branch information
Mykola Morhun
committed
Apr 1, 2016
1 parent
0275f91
commit e828e7f
Showing
32 changed files
with
2,452 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,313 changes: 1,122 additions & 191 deletions
1,313
...gin-docker-client/src/main/java/org/eclipse/che/plugin/docker/client/DockerConnector.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
...he-plugin-docker-client/src/main/java/org/eclipse/che/plugin/docker/client/json/Node.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.plugin.docker.client.json; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Describe docker node in swarm model | ||
* | ||
* @author Eugene Voevodin | ||
* @author Alexander Garagatyi | ||
*/ | ||
public class Node { | ||
|
||
private String id; | ||
private String name; | ||
private String addr; | ||
private String ip; | ||
private int cpus; | ||
private long memory; | ||
|
||
private Map<String, String> labels = new HashMap<>(); | ||
|
||
public String getID() { | ||
return id; | ||
} | ||
|
||
public void setID(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getAddr() { | ||
return addr; | ||
} | ||
|
||
public void setAddr(String addr) { | ||
this.addr = addr; | ||
} | ||
|
||
public String getIP() { | ||
return ip; | ||
} | ||
|
||
public void setIP(String ip) { | ||
this.ip = ip; | ||
} | ||
|
||
public int getCpus() { | ||
return cpus; | ||
} | ||
|
||
public void setCpus(int cpus) { | ||
this.cpus = cpus; | ||
} | ||
|
||
public long getMemory() { | ||
return memory; | ||
} | ||
|
||
public void setMemory(long memory) { | ||
this.memory = memory; | ||
} | ||
|
||
public Map<String, String> getLabels() { | ||
return labels; | ||
} | ||
|
||
public void setLabels(Map<String, String> labels) { | ||
this.labels = labels; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Node{" + | ||
"ID='" + id + '\'' + | ||
", name='" + name + '\'' + | ||
", addr='" + addr + '\'' + | ||
", IP='" + ip + '\'' + | ||
", cpus=" + cpus + | ||
", memory=" + memory + | ||
", labels=" + labels + | ||
'}'; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof Node)) return false; | ||
Node node = (Node)o; | ||
return Objects.equals(getCpus(), node.getCpus()) && | ||
Objects.equals(getMemory(), node.getMemory()) && | ||
Objects.equals(getID(), node.getID()) && | ||
Objects.equals(getName(), node.getName()) && | ||
Objects.equals(getAddr(), node.getAddr()) && | ||
Objects.equals(getIP(), node.getIP()) && | ||
Objects.equals(getLabels(), node.getLabels()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getID(), getName(), getAddr(), getIP(), getCpus(), getMemory(), getLabels()); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...ient/src/main/java/org/eclipse/che/plugin/docker/client/params/AttachContainerParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.plugin.docker.client.params; | ||
|
||
/** | ||
* Arguments holder for {@code attachContainer} method of {@link org.eclipse.che.plugin.docker.client.DockerConnector}. | ||
* | ||
* @author Mykola Morhun | ||
*/ | ||
public class AttachContainerParams { | ||
/** id of container */ | ||
private String container; | ||
/** | ||
* if {@code true} then get 'live' stream from container. Typically need to run this method in separate thread, | ||
* if {@code stream} is {@code true} since this method blocks until container is running. | ||
*/ | ||
private Boolean stream; | ||
|
||
public AttachContainerParams withContainer(String container) { | ||
this.container = container; | ||
return this; | ||
} | ||
|
||
public AttachContainerParams withStream(Boolean stream) { | ||
this.stream = stream; | ||
return this; | ||
} | ||
|
||
public String getContainer() { | ||
return container; | ||
} | ||
|
||
public Boolean isStream() { | ||
return stream; | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
...er-client/src/main/java/org/eclipse/che/plugin/docker/client/params/BuildImageParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.plugin.docker.client.params; | ||
|
||
import org.eclipse.che.plugin.docker.client.dto.AuthConfigs; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* Arguments holder for {@code buildImage} method of {@link org.eclipse.che.plugin.docker.client.DockerConnector}. | ||
* | ||
* @author Mykola Morhun | ||
*/ | ||
public class BuildImageParams { | ||
/** full repository name to be applied to newly created image */ | ||
private String repository; | ||
/** authentication configuration for private registries. Can be null */ | ||
private AuthConfigs authConfigs; | ||
/** */ | ||
private Boolean doForcePull; | ||
/** memory limit for build in bytes */ | ||
private Long memoryLimit; | ||
/** total memory in bytes (memory + swap), -1 to enable unlimited swap */ | ||
private Long memorySwapLimit; | ||
/** | ||
* files that are needed for creation docker images (e.g. file of directories used in ADD instruction in Dockerfile). | ||
* One of them must be Dockerfile. | ||
*/ | ||
private File[] files; | ||
|
||
public BuildImageParams() { | ||
doForcePull = false; | ||
} | ||
|
||
public BuildImageParams withRepository(String repository) { | ||
this.repository = repository; | ||
return this; | ||
} | ||
|
||
public BuildImageParams withAuthConfigs(AuthConfigs authConfigs) { | ||
this.authConfigs = authConfigs; | ||
return this; | ||
} | ||
|
||
public BuildImageParams withDoForcePull(Boolean doForcePull) { | ||
this.doForcePull = doForcePull; | ||
return this; | ||
} | ||
|
||
public BuildImageParams withMemoryLimit(Long memoryLimit) { | ||
this.memoryLimit = memoryLimit; | ||
return this; | ||
} | ||
|
||
public BuildImageParams withMemorySwapLimit(Long memorySwapLimit) { | ||
this.memorySwapLimit = memorySwapLimit; | ||
return this; | ||
} | ||
|
||
public BuildImageParams withFiles(File... files) { | ||
this.files = files; | ||
return this; | ||
} | ||
|
||
public String getRepository() { | ||
return repository; | ||
} | ||
|
||
public AuthConfigs getAuthConfigs() { | ||
return authConfigs; | ||
} | ||
|
||
public Boolean isDoForcePull() { | ||
return doForcePull; | ||
} | ||
|
||
public Long getMemoryLimit() { | ||
return memoryLimit; | ||
} | ||
|
||
public Long getMemorySwapLimit() { | ||
return memorySwapLimit; | ||
} | ||
|
||
public File[] getFiles() { | ||
return files; | ||
} | ||
|
||
} |
Oops, something went wrong.