Search in sources :

Example 16 with IDockerImage

use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.

the class PushImageCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final IDockerImage selectedImage = CommandUtils.getSelectedImage(activePart);
    final ImagePush wizard = new ImagePush(selectedImage, selectedImage.repo() + ":" + selectedImage.tags().get(0));
    final boolean pushImage = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
    if (pushImage) {
        final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
        performPushImage(wizard, connection);
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) ImagePush(org.eclipse.linuxtools.internal.docker.ui.wizards.ImagePush)

Example 17 with IDockerImage

use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.

the class RemoveTagCommandHandler 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);
    final ImageRemoveTag wizard = new ImageRemoveTag(image);
    final boolean removeTag = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
    if (removeTag) {
        performRemoveTagImage(connection, wizard.getTag());
    }
    return null;
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) ImageRemoveTag(org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRemoveTag)

Example 18 with IDockerImage

use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.

the class DockerConnectionTest method shouldLoadImages.

@Test
public void shouldLoadImages() throws DockerException {
    // given
    final Image fooImage = MockImageFactory.id("foo").build();
    final Image barImage = MockImageFactory.id("bar").build();
    final DockerClient client = MockDockerClientFactory.image(fooImage).image(barImage).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    dockerConnection.open(false);
    // when
    final List<IDockerImage> images = dockerConnection.getImages();
    // then
    assertThat(images).hasSize(2);
}
Also used : DockerClient(com.spotify.docker.client.DockerClient) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) Image(com.spotify.docker.client.messages.Image) Test(org.junit.Test)

Example 19 with IDockerImage

use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.

the class DockerImageTest method shouldDuplicateImageByRepo.

@Test
public void shouldDuplicateImageByRepo() {
    // given
    final IDockerImage fooImage = MockDockerImageFactory.id("sha256:foo_image").name("foo_image", "foo_image_alias:alias").build();
    // when
    final List<IDockerImage> result = DockerImage.duplicateImageByRepo(fooImage).collect(Collectors.toList());
    // then
    assertThat(result).hasSize(2);
    assertThat(result.get(0).id()).isEqualTo("sha256:foo_image");
    assertThat(result.get(0).repo()).isEqualTo("foo_image");
    assertThat(result.get(0).tags()).isEmpty();
    assertThat(result.get(1).id()).isEqualTo("sha256:foo_image");
    assertThat(result.get(1).repo()).isEqualTo("foo_image_alias");
    assertThat(result.get(1).tags()).containsExactly("alias");
}
Also used : IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) Test(org.junit.Test)

Example 20 with IDockerImage

use of org.eclipse.linuxtools.docker.core.IDockerImage in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModelTest method mockSingleImage.

private static IDockerImage mockSingleImage(IDockerConnection dockerConnection, String imageName, String tag) {
    IDockerImage image = mock(IDockerImage.class);
    when(image.repoTags()).thenReturn(Collections.singletonList(imageName + ":" + tag));
    when(dockerConnection.getImages()).thenReturn(Collections.singletonList(image));
    return image;
}
Also used : IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage)

Aggregations

IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)41 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)16 DockerException (org.eclipse.linuxtools.docker.core.DockerException)10 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)8 IDockerImageHierarchyNode (org.eclipse.linuxtools.docker.core.IDockerImageHierarchyNode)7 List (java.util.List)6 CoreException (org.eclipse.core.runtime.CoreException)6 IDockerHostConfig (org.eclipse.linuxtools.docker.core.IDockerHostConfig)6 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)5 IDockerContainer (org.eclipse.linuxtools.docker.core.IDockerContainer)5 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)5 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)5 HashMap (java.util.HashMap)4 Map (java.util.Map)3 Job (org.eclipse.core.runtime.jobs.Job)3 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)3 IDockerContainerConfig (org.eclipse.linuxtools.docker.core.IDockerContainerConfig)3 IDockerImageInfo (org.eclipse.linuxtools.docker.core.IDockerImageInfo)3 DockerContainerConfig (org.eclipse.linuxtools.internal.docker.core.DockerContainerConfig)3