Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2015-06-09 12:00:15 -0400
committerJeff Johnston2015-06-09 15:01:37 -0400
commit31b300db34c886c5a303d6b7b5a7ca4851f98af4 (patch)
tree8c76a246bba350d915d176f28dc8cc03d62bda42
parentea2015978002aa0a6f049486910a929d96f499f6 (diff)
downloadorg.eclipse.linuxtools-31b300db34c886c5a303d6b7b5a7ca4851f98af4.tar.gz
org.eclipse.linuxtools-31b300db34c886c5a303d6b7b5a7ca4851f98af4.tar.xz
org.eclipse.linuxtools-31b300db34c886c5a303d6b7b5a7ca4851f98af4.zip
Bug 469734 - Missing public setter method for selectedDataVolumes property
Also fixed other problems in the Image Run wizard: - if elelemts were selected in the Data Volumes or Exposed Ports tables, then edited, they would not be taken into account when building the image because the hash values would have changed. Using an UUID as the unique element to compute the equals/hashcode fixed that problem - the code to mount data volumes was wrong, the data volumes Change-Id: Iee634178ad3bfd07559a77dcbf765915f7d6fbd0 Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/49819 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com> (cherry picked from commit 75cd51ad4bd6f8b59296365bae83de067c52601b) Reviewed-on: https://git.eclipse.org/r/49827
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/DataVolumeModel.java26
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRun.java47
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesModel.java6
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java33
4 files changed, 32 insertions, 80 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/DataVolumeModel.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/DataVolumeModel.java
index d071639e06..0a670b03c5 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/DataVolumeModel.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/DataVolumeModel.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.docker.ui.wizards;
+import java.util.UUID;
+
import org.eclipse.linuxtools.internal.docker.ui.databinding.BaseDatabindingModel;
import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunResourceVolumesVariablesModel.MountType;
@@ -32,6 +34,8 @@ public class DataVolumeModel extends BaseDatabindingModel
public static final String CONTAINER_MOUNT = "containerMount";
+ private final String id = UUID.randomUUID().toString();
+
private String containerPath;
private MountType mountType;
@@ -150,12 +154,7 @@ public class DataVolumeModel extends BaseDatabindingModel
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result
- + ((containerPath == null) ? 0 : containerPath.hashCode());
- result = prime * result + ((mount == null) ? 0 : mount.hashCode());
- result = prime * result
- + ((mountType == null) ? 0 : mountType.hashCode());
- result = prime * result + (readOnly ? 1231 : 1237);
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@@ -168,19 +167,10 @@ public class DataVolumeModel extends BaseDatabindingModel
if (getClass() != obj.getClass())
return false;
DataVolumeModel other = (DataVolumeModel) obj;
- if (containerPath == null) {
- if (other.containerPath != null)
- return false;
- } else if (!containerPath.equals(other.containerPath))
- return false;
- if (mount == null) {
- if (other.mount != null)
+ if (id == null) {
+ if (other.id != null)
return false;
- } else if (!mount.equals(other.mount))
- return false;
- if (mountType != other.mountType)
- return false;
- if (readOnly != other.readOnly)
+ } else if (!id.equals(other.id))
return false;
return true;
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRun.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRun.java
index ddff2a2a1a..13399af89d 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRun.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRun.java
@@ -14,11 +14,9 @@ package org.eclipse.linuxtools.internal.docker.ui.wizards;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
@@ -142,6 +140,7 @@ public class ImageRun extends Wizard {
// data volumes
final List<String> volumesFrom = new ArrayList<>();
+ final List<String> binds = new ArrayList<>();
for (Iterator<DataVolumeModel> iterator = resourcesModel
.getDataVolumes().iterator(); iterator.hasNext();) {
final DataVolumeModel dataVolume = iterator.next();
@@ -152,6 +151,15 @@ public class ImageRun extends Wizard {
}
switch (dataVolume.getMountType()) {
+ case HOST_FILE_SYSTEM:
+ if (dataVolume.isReadOnly()) {
+ binds.add(dataVolume.getHostPathMount() + ':'
+ + dataVolume.getContainerPath() + ':' + "ro");
+ } else {
+ binds.add(dataVolume.getHostPathMount() + ':'
+ + dataVolume.getContainerPath());
+ }
+ break;
case CONTAINER:
volumesFrom.add(dataVolume.getContainerMount());
break;
@@ -160,6 +168,7 @@ public class ImageRun extends Wizard {
}
}
+ hostConfigBuilder.binds(binds);
hostConfigBuilder.volumesFrom(volumesFrom);
return hostConfigBuilder.build();
@@ -190,40 +199,6 @@ public class ImageRun extends Wizard {
environmentVariables.add(var.getName() + "=" + var.getValue());
}
config.env(environmentVariables);
-
- // container data volumes
- final Set<String> volumes = new HashSet<>();
- for (Iterator<DataVolumeModel> iterator = resourcesModel
- .getDataVolumes().iterator(); iterator.hasNext();) {
- final DataVolumeModel dataVolume = iterator.next();
- // only data volumes selected in the CheckBoxTableViewer are
- // included.
- if (!resourcesModel.getSelectedDataVolumes().contains(dataVolume)) {
- continue;
- }
- switch (dataVolume.getMountType()) {
- case CONTAINER:
- // different way to configure 'volumes-from'
- break;
- case HOST_FILE_SYSTEM:
- if (dataVolume.isReadOnly()) {
- volumes.add(dataVolume.getContainerPath() + ':'
- + dataVolume.getHostPathMount() + ':' + "ro");
- } else {
- volumes.add(dataVolume.getContainerPath() + ':'
- + dataVolume.getHostPathMount());
- }
- break;
- case NONE:
- volumes.add(dataVolume.getContainerPath());
- break;
- default:
- break;
-
- }
- }
- config.volumes(volumes);
-
return config.build();
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesModel.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesModel.java
index 5456fc3886..30d9628c67 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesModel.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesModel.java
@@ -123,6 +123,12 @@ public class ImageRunResourceVolumesVariablesModel
return selectedDataVolumes;
}
+ public void setSelectedDataVolumes(
+ Set<DataVolumeModel> selectedDataVolumes) {
+ firePropertyChange(SELECTED_DATA_VOLUMES, this.selectedDataVolumes,
+ this.selectedDataVolumes = selectedDataVolumes);
+ }
+
public WritableList getEnvironmentVariables() {
return environmentVariables;
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java
index 1d30513cb5..40abe1eeb1 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java
@@ -17,6 +17,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.UUID;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.core.runtime.Assert;
@@ -314,6 +315,8 @@ public class ImageRunSelectionModel extends BaseDatabindingModel {
public static final String HOST_PORT = "hostPort";
+ private final String id = UUID.randomUUID().toString();
+
private boolean selected;
private String containerPort;
@@ -391,14 +394,7 @@ public class ImageRunSelectionModel extends BaseDatabindingModel {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result
- + ((hostAddress == null) ? 0 : hostAddress.hashCode());
- result = prime * result
- + ((containerPort == null) ? 0 : containerPort.hashCode());
- result = prime * result
- + ((hostPort == null) ? 0 : hostPort.hashCode());
- result = prime * result
- + ((portType == null) ? 0 : portType.hashCode());
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@@ -411,25 +407,10 @@ public class ImageRunSelectionModel extends BaseDatabindingModel {
if (getClass() != obj.getClass())
return false;
ExposedPortModel other = (ExposedPortModel) obj;
- if (hostAddress == null) {
- if (other.hostAddress != null)
- return false;
- } else if (!hostAddress.equals(other.hostAddress))
- return false;
- if (containerPort == null) {
- if (other.containerPort != null)
- return false;
- } else if (!containerPort.equals(other.containerPort))
- return false;
- if (hostPort == null) {
- if (other.hostPort != null)
- return false;
- } else if (!hostPort.equals(other.hostPort))
- return false;
- if (portType == null) {
- if (other.portType != null)
+ if (id == null) {
+ if (other.id != null)
return false;
- } else if (!portType.equals(other.portType))
+ } else if (!id.equals(other.id))
return false;
return true;
}

Back to the top