use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class DockerImageLabels method getImageStreamTag.
private String getImageStreamTag(String imageDigest, String imageRef, String namespace, Connection connection) {
List<IResource> imageStreamTags = connection.getResources(ResourceKind.IMAGE_STREAM_TAG, namespace);
IResource imageStreamTag = ResourceUtils.getImageStreamTagForDigest(imageDigest, imageStreamTags);
if (imageStreamTag == null) {
return null;
}
// load image stream tag individually to get full ContainerConfig metadata
imageStreamTag = connection.getResource(ResourceKind.IMAGE_STREAM_TAG, namespace, imageStreamTag.getName());
return imageStreamTag.toJson();
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class OpenShiftServerUtils method getAllPods.
/**
* Returns all pods for the given server. Returns an empty list otherwise.
*
* @param server
* @return
*/
public static Collection<IPod> getAllPods(IServer server, IProgressMonitor monitor) {
Connection connection = getConnection(server);
if (connection == null) {
return Collections.emptyList();
}
IResource resource = getResource(server, connection, monitor);
if (resource == null) {
return Collections.emptyList();
}
List<IPod> collection = new ArrayList<>();
List<IPod> pods = connection.getResources(ResourceKind.POD, resource.getNamespaceName());
List<IPod> servicePods = ResourceUtils.getPodsFor(resource, pods);
collection.addAll(pods);
collection.addAll(servicePods);
return collection;
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class ImportApplicationHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = UIUtils.getCurrentSelection(event);
IBuildConfig buildConfig = UIUtils.getFirstElement(currentSelection, IBuildConfig.class);
Map<IProject, Collection<IBuildConfig>> projectsAndBuildConfigs = null;
IProject project = null;
Collection<IBuildConfig> buildConfigs = null;
if (buildConfig == null) {
IResource resource = UIUtils.getFirstElement(currentSelection, IResource.class);
if (resource != null) {
project = resource.getProject();
}
if (project != null) {
buildConfigs = project.getResources(ResourceKind.BUILD_CONFIG);
}
} else {
project = buildConfig.getProject();
buildConfigs = Collections.singleton(buildConfig);
}
if (project != null) {
if (buildConfigs == null || buildConfigs.isEmpty()) {
MessageDialog.openWarning(HandlerUtil.getActiveShell(event), NO_BUILD_CONFIG_MSG, NO_BUILD_CONFIG_MSG);
return OpenShiftUIActivator.statusFactory().cancelStatus(NO_BUILD_CONFIG_MSG);
}
projectsAndBuildConfigs = Collections.singletonMap(project, buildConfigs);
}
if (projectsAndBuildConfigs == null) {
ImportApplicationWizard wizard = new ImportApplicationWizard();
Connection connection = UIUtils.getFirstElement(currentSelection, Connection.class);
wizard.setConnection(connection);
WizardUtils.openWizardDialog(wizard, HandlerUtil.getActiveShell(event));
} else {
WizardUtils.openWizardDialog(new ImportApplicationWizard(projectsAndBuildConfigs), HandlerUtil.getActiveShell(event));
}
return Status.OK_STATUS;
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class ScaleDeploymentHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IDeploymentConfig dc = getDeploymentConfig(getSelectedElement(event, IResourceWrapper.class));
if (dc == null) {
IResource resource = ResourceWrapperUtils.getResource(UIUtils.getFirstElement(HandlerUtil.getCurrentSelection(event)));
return OpenShiftUIActivator.statusFactory().errorStatus(NLS.bind("Could not scale {0}: Could not find deployment config", resource == null ? "" : resource.getName()));
}
scaleUsing(event, dc, dc.getName());
return null;
}
use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.
the class OpenInWebConsoleHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection currentSelection = UIUtils.getCurrentSelection(event);
IResource resource = UIUtils.getFirstElement(currentSelection, IResource.class);
Connection connection = null;
if (resource == null) {
connection = UIUtils.getFirstElement(currentSelection, Connection.class);
} else {
connection = ConnectionsRegistryUtil.safeGetConnectionFor(resource);
}
String msg;
if (connection == null) {
msg = "Could not find an OpenShift connection to open a console for";
} else {
String url = getWebConsoleUrl(connection, resource);
if (!StringUtils.isEmpty(url)) {
new BrowserUtility().checkedCreateExternalBrowser(url, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
return Status.OK_STATUS;
}
msg = NLS.bind("Could not determine the url for the web console on {0}", connection.getHost());
}
MessageDialog.openWarning(HandlerUtil.getActiveShell(event), "No Web Console Url", msg);
return new Status(IStatus.WARNING, OpenShiftUIActivator.PLUGIN_ID, msg);
}
Aggregations