Skip to content

Commit

Permalink
CHE-253: Refactor Che docker client to be able to add new parameters …
Browse files Browse the repository at this point in the history
…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
Show file tree
Hide file tree
Showing 32 changed files with 2,452 additions and 226 deletions.
4 changes: 4 additions & 0 deletions plugins/plugin-docker/che-plugin-docker-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-dto</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-gwt</artifactId>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* @author andrew00x
*/
public class ContainerCommited {
public class ContainerCommitted {
private String id;

public String getId() {
Expand All @@ -26,7 +26,7 @@ public void setId(String id) {

@Override
public String toString() {
return "ContainerCommited{" +
return "ContainerCommitted{" +
"id='" + id + '\'' +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ContainerInfo {
private ContainerState state;
private String image;
private NetworkSettings networkSettings;
private String resolvConfPath;
private String resolveConfPath;
private HostConfig hostConfig;
private String driver;
private String execDriver;
Expand All @@ -38,6 +38,7 @@ public class ContainerInfo {
private String[] execIDs;
private int restartCount;
private String logPath;
private Node node;

private Map<String, String> volumes = new HashMap<>();
private Map<String, Boolean> volumesRW = new HashMap<>();
Expand Down Expand Up @@ -106,12 +107,12 @@ public void setNetworkSettings(NetworkSettings networkSettings) {
this.networkSettings = networkSettings;
}

public String getResolvConfPath() {
return resolvConfPath;
public String getResolveConfPath() {
return resolveConfPath;
}

public void setResolvConfPath(String resolvConfPath) {
this.resolvConfPath = resolvConfPath;
public void setResolveConfPath(String resolveConfPath) {
this.resolveConfPath = resolveConfPath;
}

public Map<String, String> getVolumes() {
Expand Down Expand Up @@ -226,6 +227,14 @@ public void setLogPath(String logPath) {
this.logPath = logPath;
}

public Node getNode() {
return node;
}

public void setNode(Node node) {
this.node = node;
}

@Override
public String toString() {
return "ContainerInfo{" +
Expand All @@ -238,7 +247,7 @@ public String toString() {
", state=" + state +
", image='" + image + '\'' +
", networkSettings=" + networkSettings +
", resolvConfPath='" + resolvConfPath + '\'' +
", resolveConfPath='" + resolveConfPath + '\'' +
", hostConfig=" + hostConfig +
", driver='" + driver + '\'' +
", execDriver='" + execDriver + '\'' +
Expand All @@ -252,6 +261,7 @@ public String toString() {
", logPath='" + logPath + '\'' +
", volumes=" + volumes +
", volumesRW=" + volumesRW +
", node=" + node +
'}';
}
}
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());
}
}
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;
}
}
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;
}

}
Loading

0 comments on commit e828e7f

Please sign in to comment.