Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2015-11-24 08:21:42 +0000
committerXavier Coulon2015-11-25 15:46:04 +0000
commit22ec078ee9b1257ccda419b0187d011838a63ac6 (patch)
tree987948c9ef694f639618156011c6469194ec7a84 /containers/org.eclipse.linuxtools.docker.core/src/org/eclipse
parentdb8dd4400d77b4a5583656f0dd13598d95b87f14 (diff)
downloadorg.eclipse.linuxtools-22ec078ee9b1257ccda419b0187d011838a63ac6.tar.gz
org.eclipse.linuxtools-22ec078ee9b1257ccda419b0187d011838a63ac6.tar.xz
org.eclipse.linuxtools-22ec078ee9b1257ccda419b0187d011838a63ac6.zip
Bug 481219 - Validate container name in "Image Run" wizard
Raise an error message when a container with the same name exists. Also added checks to avoid NPE when initializing ContainerInfo and ImageInfo Refactored some SWT utility classes used to setup the mock connection and moved some reusable blocks in JUnit rules. Change-Id: Ie8363fb4af6e8e5d210734c7f9028b27ac70548a Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/61113 Tested-by: Hudson CI
Diffstat (limited to 'containers/org.eclipse.linuxtools.docker.core/src/org/eclipse')
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java3
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnectionInfo.java51
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainerInfo.java42
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerImageInfo.java28
4 files changed, 66 insertions, 58 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
index 57fc86cee1..a67f905e5e 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
@@ -971,7 +971,8 @@ public class DockerConnection implements IDockerConnection, Closeable {
final ContainerCreation creation = client
.createContainer(builder.build(),
containerName);
- final String id = creation.id();
+
+ final String id = creation != null ? creation.id() : null;
// force a refresh of the current containers to include the new one
listContainers();
return id;
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnectionInfo.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnectionInfo.java
index a4b8e548ae..73bb1e3ebf 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnectionInfo.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnectionInfo.java
@@ -53,31 +53,32 @@ public class DockerConnectionInfo implements IDockerConnectionInfo {
private final String dockerRootDir;
public DockerConnectionInfo(final Info info, final Version version) {
- this.containers = info.containers();
- this.debug = info.debug();
- this.executionDriver = info.executionDriver();
- this.fileDescriptors = info.fileDescriptors();
- this.goroutines = info.goroutines();
- this.images = info.images();
- this.initPath = info.initPath();
- this.kernelVersion = info.kernelVersion();
- this.memoryLimit = info.memoryLimit();
- this.storageDriver = info.storageDriver();
- this.swapLimit = info.swapLimit();
- this.apiVersion = version.apiVersion();
- this.gitCommit = version.gitCommit();
- this.os = version.os();
- this.version = version.version();
- this.driverStatus = info.driverStatus();
- this.cpuNumber = info.cpus();
- this.totalMemory = info.memTotal();
- this.name = info.name();
- this.id = info.id();
- this.initSha1 = info.initSha1();
- this.ipv4Forwarding = info.ipv4Forwarding();
- this.indexServerAddress = info.indexServerAddress();
- this.labels = info.labels();
- this.dockerRootDir = info.dockerRootDir();
+ this.containers = info != null ? info.containers() : -1;
+ this.debug = info != null ? info.debug() : false;
+ this.executionDriver = info != null ? info.executionDriver() : null;
+ this.fileDescriptors = info != null ? info.fileDescriptors() : -1;
+ this.goroutines = info != null ? info.goroutines() : -1;
+ this.images = info != null ? info.images() : -1;
+ this.initPath = info != null ? info.initPath() : null;
+ this.kernelVersion = info != null ? info.kernelVersion() : null;
+ this.memoryLimit = info != null ? info.memoryLimit() : false;
+ this.storageDriver = info != null ? info.storageDriver() : null;
+ this.swapLimit = info != null ? info.swapLimit() : false;
+ this.apiVersion = version != null ? version.apiVersion() : null;
+ this.gitCommit = version != null ? version.gitCommit() : null;
+ this.os = version != null ? version.os() : "";
+ this.version = version != null ? version.version() : null;
+ this.driverStatus = info != null ? info.driverStatus() : null;
+ this.cpuNumber = info != null ? info.cpus() : -1;
+ this.totalMemory = info != null ? info.memTotal() : -1;
+ this.name = info != null ? info.name() : null;
+ this.id = info != null ? info.id() : null;
+ this.initSha1 = info != null ? info.initSha1() : null;
+ this.ipv4Forwarding = info != null ? info.ipv4Forwarding() : false;
+ this.indexServerAddress = info != null ? info.indexServerAddress()
+ : null;
+ this.labels = info != null ? info.labels() : null;
+ this.dockerRootDir = info != null ? info.dockerRootDir() : null;
}
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainerInfo.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainerInfo.java
index 84d7db1004..f40f68cbe9 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainerInfo.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainerInfo.java
@@ -45,25 +45,29 @@ public class DockerContainerInfo implements IDockerContainerInfo {
private Map<String, Boolean> volumesRW;
public DockerContainerInfo (final ContainerInfo info) {
- this.id = info.id();
- this.created = info.created();
- this.path = info.path();
- this.args = info.args();
- this.config = new DockerContainerConfig(info.config());
- this.hostConfig = new DockerHostConfig(info.hostConfig());
- this.state = new DockerContainerState(info.state());
- this.image = info.image();
- this.networkSettings = new DockerNetworkSettings(info.networkSettings());
- this.resolvConfPath = info.resolvConfPath();
- this.hostnamePath = info.hostnamePath();
- this.hostsPath = info.hostsPath();
- this.name = info.name();
- this.driver = info.driver();
- this.execDriver = info.execDriver();
- this.processLabel = info.processLabel();
- this.mountLabel = info.mountLabel();
- this.volumes = info.volumes();
- this.volumesRW = info.volumesRW();
+ this.id = info != null ? info.id() : null;
+ this.created = info != null ? info.created() : null;
+ this.path = info != null ? info.path() : null;
+ this.args = info != null ? info.args() : null;
+ this.config = info != null ? new DockerContainerConfig(info.config())
+ : null;
+ this.hostConfig = info != null ? new DockerHostConfig(info.hostConfig())
+ : null;
+ this.state = info != null ? new DockerContainerState(info.state())
+ : null;
+ this.image = info != null ? info.image() : null;
+ this.networkSettings = info != null
+ ? new DockerNetworkSettings(info.networkSettings()) : null;
+ this.resolvConfPath = info != null ? info.resolvConfPath() : null;
+ this.hostnamePath = info != null ? info.hostnamePath() : null;
+ this.hostsPath = info != null ? info.hostsPath() : null;
+ this.name = info != null ? info.name() : null;
+ this.driver = info != null ? info.driver() : null;
+ this.execDriver = info != null ? info.execDriver() : null;
+ this.processLabel = info != null ? info.processLabel() : null;
+ this.mountLabel = info != null ? info.mountLabel() : null;
+ this.volumes = info != null ? info.volumes() : null;
+ this.volumesRW = info != null ? info.volumesRW() : null;
}
@Override
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerImageInfo.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerImageInfo.java
index 0514885f65..e9aff6f837 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerImageInfo.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerImageInfo.java
@@ -32,19 +32,21 @@ public class DockerImageInfo implements IDockerImageInfo {
private String os;
private Long size;
- public DockerImageInfo(ImageInfo info) {
- this.id = info.id();
- this.parent = info.parent();
- this.comment = info.comment();
- this.created = info.created();
- this.container = info.container();
- this.containerConfig = new DockerContainerConfig(info.containerConfig());
- this.dockerVersion = info.dockerVersion();
- this.author = info.author();
- this.config = new DockerContainerConfig(info.config());
- this.architecture = info.architecture();
- this.os = info.os();
- this.size = info.size();
+ public DockerImageInfo(final ImageInfo info) {
+ this.id = info != null ? info.id() : null;
+ this.parent = info != null ? info.parent() : null;
+ this.comment = info != null ? info.comment() : null;
+ this.created = info != null ? info.created() : null;
+ this.container = info != null ? info.container() : null;
+ this.containerConfig = info != null
+ ? new DockerContainerConfig(info.containerConfig()) : null;
+ this.dockerVersion = info != null ? info.dockerVersion() : null;
+ this.author = info != null ? info.author() : null;
+ this.config = info != null ? new DockerContainerConfig(info.config())
+ : null;
+ this.architecture = info != null ? info.architecture() : null;
+ this.os = info != null ? info.os() : null;
+ this.size = info != null ? info.size() : null;
}
@Override

Back to the top