Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2018-05-18 16:23:31 -0400
committerJeff Johnston2018-05-22 13:49:17 -0400
commit975a665d3b7b3dcb9a9c647695067990091da601 (patch)
tree44a4ce52eec493551be4daa712f00631cfe4eabc
parentb5a32d280cecff0245d2a988d43a0cda43ce03d0 (diff)
downloadorg.eclipse.linuxtools-975a665d3b7b3dcb9a9c647695067990091da601.tar.gz
org.eclipse.linuxtools-975a665d3b7b3dcb9a9c647695067990091da601.tar.xz
org.eclipse.linuxtools-975a665d3b7b3dcb9a9c647695067990091da601.zip
Bug 534725 - Cannot run locally built image with Launch Configuration
- add getImage() method to IDockerConnection2 interface - fix getImage() method in DockerConnection to not log an error if image not found, just return null - modify ImageRunSelectionModel validator to add logic if the image name isn't found in the image list, then try and get Image info for the id if the length is >5 and return an IDockerImage if info is found Change-Id: Ieb074a339e7a9eb6dc58c428fa94e4beaeb68ac2 Reviewed-on: https://git.eclipse.org/r/122984 Tested-by: CI Bot Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection2.java9
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java4
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionModel.java8
3 files changed, 20 insertions, 1 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection2.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection2.java
index f4bbddbbba..b5e985f460 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection2.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection2.java
@@ -73,4 +73,13 @@ public interface IDockerConnection2 {
*/
IDockerImageHierarchyNode resolveImageHierarchy(IDockerContainer container);
+ /**
+ * Retrieve an Image by id
+ *
+ * @param id
+ * of Image
+ * @return the IDockerImage or null if not found
+ */
+ IDockerImage getImage(String id);
+
}
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 73dc4a0759..76e6b2c254 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
@@ -945,6 +945,8 @@ public class DockerConnection
Activator.logErrorMessage(
ProcessMessages.getString("Image_Info_Exception"), e); //$NON-NLS-1$
return null;
+ } catch (com.spotify.docker.client.exceptions.ImageNotFoundException e) {
+ return null;
} catch (com.spotify.docker.client.exceptions.DockerException
| InterruptedException e) {
Activator.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
@@ -1005,7 +1007,7 @@ public class DockerConnection
* @param id
* the {@link IDockerImage} id
*/
- // TODO: declare the method in the interface to make it part of the API.
+ @Override
public IDockerImage getImage(String id) {
List<IDockerImage> images = getImages();
for (IDockerImage image : images) {
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 a17a2f74af..8489622538 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
@@ -26,7 +26,9 @@ import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.core.runtime.Assert;
import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
import org.eclipse.linuxtools.docker.core.IDockerConnection;
+import org.eclipse.linuxtools.docker.core.IDockerConnection2;
import org.eclipse.linuxtools.docker.core.IDockerImage;
+import org.eclipse.linuxtools.docker.core.IDockerImageInfo;
import org.eclipse.linuxtools.internal.docker.ui.databinding.BaseDatabindingModel;
/**
@@ -235,6 +237,12 @@ public class ImageRunSelectionModel extends BaseDatabindingModel {
* was found.
*/
public IDockerImage getSelectedImage() {
+ if (this.images.get(selectedImageName) == null && selectedImageName != null && selectedImageName.length() > 5) {
+ IDockerImageInfo info = getSelectedConnection().getImageInfo(selectedImageName);
+ if (info != null) {
+ return ((IDockerConnection2) getSelectedConnection()).getImage(info.id());
+ }
+ }
return this.images.get(selectedImageName);
}

Back to the top