Search in sources :

Example 86 with IDockerConnection

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

the class TagImageCommandHandler method performTagImage.

private void performTagImage(final IDockerConnection connection, final IDockerImage image, final String tag) {
    final Job tagImageJob = new Job(DVMessages.getString(TAG_IMAGE_JOB_TITLE)) {

        @Override
        protected IStatus run(final IProgressMonitor monitor) {
            monitor.beginTask(DVMessages.getFormattedString(TAG_IMAGE_MSG, tag), 2);
            // handler refresh the images when done
            try {
                ((DockerConnection) connection).tagImage(image.id(), tag);
                monitor.worked(1);
                ((DockerConnection) connection).getImages(true);
                monitor.worked(1);
            } catch (final DockerException e) {
                Display.getDefault().syncExec(() -> MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DVMessages.getFormattedString(ERROR_TAGGING_IMAGE, tag), e.getMessage()));
            // for now
            } catch (InterruptedException e) {
            // do nothing
            } finally {
                monitor.done();
            }
            return Status.OK_STATUS;
        }
    };
    tagImageJob.schedule();
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerException(org.eclipse.linuxtools.docker.core.DockerException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Job(org.eclipse.core.runtime.jobs.Job)

Example 87 with IDockerConnection

use of org.eclipse.linuxtools.docker.core.IDockerConnection 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;
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) ImageTag(org.eclipse.linuxtools.internal.docker.ui.wizards.ImageTag) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage)

Example 88 with IDockerConnection

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

the class CDKDockerUtilityTest method testCreateDockerConnection.

@Test
public void testCreateDockerConnection() throws Exception {
    String name = "foo";
    IServer server = mockServer(name);
    ServiceManagerEnvironment adb = createADB("10.1.2.2");
    IDockerConnection dockerConnection = util.createDockerConnection(server, adb);
    assertNotNull(dockerConnection);
    verify(mgr).addConnection(dockerConnection);
    assertEquals(name, dockerConnection.getName());
    assertEquals("https://10.1.2.2:2376", dockerConnection.getUri());
    assertEquals("/cert/path/.docker", dockerConnection.getTcpCertPath());
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ServiceManagerEnvironment(org.jboss.tools.openshift.cdk.server.core.internal.listeners.ServiceManagerEnvironment) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) Test(org.junit.Test)

Example 89 with IDockerConnection

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

the class ConfigureDependentFrameworksListener method configureDocker.

private void configureDocker(IServer server, ServiceManagerEnvironment adb) {
    try {
        CDKDockerUtility util = new CDKDockerUtility();
        IDockerConnection dc = util.findDockerConnection(server.getName());
        if (dc != null) {
            // update
            util.updateConnection(dc, server.getName(), adb);
        } else {
            // create
            util.createDockerConnection(server, adb);
        }
    } catch (DockerException de) {
        CDKCoreActivator.pluginLog().logError("Error while creating docker connection for server " + server.getName(), de);
    }
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Example 90 with IDockerConnection

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

the class CDKDockerUtility method createDockerConnection.

public IDockerConnection createDockerConnection(IServer server, ServiceManagerEnvironment adb) throws DockerException {
    IDockerConnection con = buildDockerConnection(server.getName(), adb);
    mgr.addConnection(con);
    return con;
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

Aggregations

IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)90 DockerException (org.eclipse.linuxtools.docker.core.DockerException)24 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)20 Job (org.eclipse.core.runtime.jobs.Job)17 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)16 IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)15 Test (org.junit.Test)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)12 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)9 File (java.io.File)8 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 IDockerContainer (org.eclipse.linuxtools.docker.core.IDockerContainer)8 IPath (org.eclipse.core.runtime.IPath)7 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)7 List (java.util.List)5 IDockerConnectionStorageManager (org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)5 RunConsole (org.eclipse.linuxtools.internal.docker.ui.consoles.RunConsole)5 DockerClient (com.spotify.docker.client.DockerClient)4 HashMap (java.util.HashMap)4