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();
}
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;
}
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());
}
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);
}
}
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;
}
Aggregations