use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class RemoveImagesCommandHandler method confirmed.
@Override
boolean confirmed(List<IDockerImage> selectedImages) {
// ask for confirmation before deleting images
List<String> imagesToRemove = new ArrayList<>();
for (IDockerImage image : selectedImages) {
// think this will ever cause an issue
if (!image.isDangling() && !image.isIntermediateImage())
imagesToRemove.add(image.repoTags().get(0));
else
imagesToRemove.add(image.id().substring(0, 8));
}
final List<String> names = imagesToRemove;
final DialogResponse response = new DialogResponse();
Display.getDefault().syncExec(() -> {
boolean result = MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DVMessages.getString(IMAGE_DELETE_CONFIRM), DVMessages.getFormattedString(IMAGE_DELETE_LIST, names.toString()));
response.setResponse(result);
});
return response.getResponse();
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class RunImageCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final IDockerImage selectedImage = CommandUtils.getSelectedImage(activePart);
if (selectedImage == null) {
Activator.log(new DockerException(// $NON-NLS-1$
DVMessages.getString("RunImageUnableToRetrieveError.msg")));
} else {
try {
final ImageRun wizard = new ImageRun(selectedImage);
final boolean runImage = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
if (runImage) {
final IDockerContainerConfig containerConfig = wizard.getDockerContainerConfig();
final IDockerHostConfig hostConfig = wizard.getDockerHostConfig();
runImage(selectedImage, containerConfig, hostConfig, wizard.getDockerContainerName(), wizard.removeWhenExits());
}
} catch (DockerException | CoreException e) {
Activator.log(e);
}
}
return null;
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class TagImageCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<IDockerImage> selectedImages = CommandUtils.getSelectedImages(activePart);
final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
if (selectedImages.size() != 1 || connection == null) {
Activator.log(new DockerException(CommandMessages.getString(// $NON-NLS-1$
"Command.missing.selection.failure")));
return null;
}
final IDockerImage image = selectedImages.get(0);
// TODO: remove the cast to DockerImage once the 'shortId' method has
// been added in the API
final ImageTag wizard = new ImageTag(((DockerImage) image).shortId());
final boolean tagImage = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
if (tagImage) {
performTagImage(connection, image, wizard.getTag());
}
return null;
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project jbosstools-openshift by jbosstools.
the class ListDockerImagesWizardModel method setDockerImages.
public void setDockerImages(final List<IDockerImage> dockerImages) {
final List<IDockerImage> topLevelImages = dockerImages.stream().filter(image -> !image.isDangling() && !image.isIntermediateImage()).collect(Collectors.toList());
final List<DockerImageTag> imageTags = new ArrayList<>();
for (IDockerImage topLevelImage : topLevelImages) {
final Map<String, List<String>> repoTags = DockerImageUtils.extractTagsByRepo(topLevelImage.repoTags());
for (Entry<String, List<String>> entry : repoTags.entrySet()) {
final String repo = entry.getKey();
final List<String> tags = entry.getValue();
for (String tag : tags) {
imageTags.add(new DockerImageTag(topLevelImage.id(), repo, tag));
}
}
}
Collections.sort(imageTags, new Comparator<DockerImageTag>() {
@Override
public int compare(DockerImageTag image1, DockerImageTag image2) {
return image1.getRepoName().compareTo(image2.getRepoName());
}
});
firePropertyChange(DOCKER_IMAGES, this.dockerImages, this.dockerImages = imageTags);
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project jbosstools-openshift by jbosstools.
the class DockerImageUtils method hasImage.
/**
* Checks if an image with the given {@code repo} and {@code tag} exists in
* the given {@code dockerConnection}
* <p>
* Workaround until https://bugs.eclipse.org/bugs/show_bug.cgi?id=495243 is
* fixed.
* </p>
*
* @param dockerConnection
* the {@link IDockerConnection}
* @param repoName
* the repository/name of the image to look-up
* @param tag
* the image tag
* @return <code>true</code> if match found, <code>false</code> otherwise
*/
public static boolean hasImage(final IDockerConnection dockerConnection, final String repoName, final String tag) {
for (IDockerImage image : dockerConnection.getImages()) {
final Map<String, List<String>> repoTags = extractTagsByRepo(image.repoTags());
for (Entry<String, List<String>> entry : repoTags.entrySet()) {
final String repo = entry.getKey();
final List<String> tags = entry.getValue();
if (repo != null && repo.equals(repoName) && tags != null && tags.contains(tag)) {
return true;
}
}
}
return false;
}
Aggregations