use of org.jboss.tools.openshift.core.odo.ServiceTemplate in project jbosstools-openshift by jbosstools.
the class CreateServiceHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
ApplicationElement application = null;
ProjectElement project = UIUtils.getFirstElement(selection, ProjectElement.class);
if (project == null) {
application = UIUtils.getFirstElement(selection, ApplicationElement.class);
if (application == null) {
// $NON-NLS-1$
return OpenShiftUIActivator.statusFactory().cancelStatus("No project or application selected");
}
project = application.getParent();
}
try {
Odo odo = project.getParent().getOdo();
List<ServiceTemplate> templates = odo.getServiceTemplates();
if (!templates.isEmpty()) {
final IWizard createServiceWizard = new CreateServiceWizard(templates, project.getWrapped(), application == null ? "" : application.getWrapped().getName(), odo);
if (WizardUtils.openWizardDialog(createServiceWizard, HandlerUtil.getActiveShell(event)) == Window.OK) {
if (application == null) {
project.refresh();
} else {
application.refresh();
}
}
} else {
MessageDialog.openWarning(HandlerUtil.getActiveShell(event), "Create service", "No operators installed on your cluster, can't create services");
}
return Status.OK_STATUS;
} catch (IOException e) {
String title = "Unable to create service";
String message = e.getMessage();
MessageDialog.open(MessageDialog.ERROR, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message, SWT.NONE);
return OpenShiftUIActivator.statusFactory().errorStatus(e);
}
}
use of org.jboss.tools.openshift.core.odo.ServiceTemplate in project jbosstools-openshift by jbosstools.
the class ServiceTemplateTest method verifyThatServiceTemplatesReturnsCRDInfo.
@Test
public void verifyThatServiceTemplatesReturnsCRDInfo() throws IOException {
List<ServiceTemplate> serviceTemplates = MAPPER.readValue(url, new TypeReference<List<ServiceTemplate>>() {
});
Assert.assertNotNull(serviceTemplates);
Assert.assertEquals(1, serviceTemplates.size());
ServiceTemplate serviceTemplate = serviceTemplates.get(0);
Assert.assertNotNull(serviceTemplate);
Assert.assertEquals("strimzi-cluster-operator.v0.25.0", serviceTemplate.getName());
assertTrue(serviceTemplate instanceof ServiceTemplate);
ServiceTemplate operatorServiceTemplate = (ServiceTemplate) serviceTemplate;
assertNotNull(operatorServiceTemplate.getCRDs());
assertEquals(9, operatorServiceTemplate.getCRDs().size());
OperatorCRD crd = operatorServiceTemplate.getCRDs().get(0);
assertEquals("kafkas.kafka.strimzi.io", crd.getName());
assertEquals("v1beta2", crd.getVersion());
assertEquals("Kafka", crd.getKind());
assertEquals("Kafka", crd.getDisplayName());
assertEquals("Represents a Kafka cluster", crd.getDescription());
assertNotNull(crd.getSample());
assertNull(crd.getSchema());
assertNotNull(crd.getSpecDescriptors());
assertEquals(7, crd.getSpecDescriptors().size());
OperatorCRDSpecDescriptor descriptor = crd.getSpecDescriptors().get(0);
assertEquals("kafka.version", descriptor.getPath());
assertEquals("Version", descriptor.getDisplayName());
assertEquals("Kafka version", descriptor.getDescription());
assertEquals(1, descriptor.getDescriptors().size());
assertEquals("urn:alm:descriptor:com.tectonic.ui:text", descriptor.getDescriptors().get(0));
}
use of org.jboss.tools.openshift.core.odo.ServiceTemplate in project jbosstools-openshift by jbosstools.
the class ServiceTemplateTest method verifyThatServiceTemplatesReturnsName.
@Test
public void verifyThatServiceTemplatesReturnsName() throws IOException {
List<ServiceTemplate> serviceTemplates = MAPPER.readValue(url, new TypeReference<List<ServiceTemplate>>() {
});
Assert.assertNotNull(serviceTemplates);
Assert.assertEquals(1, serviceTemplates.size());
ServiceTemplate serviceTemplate = serviceTemplates.get(0);
Assert.assertNotNull(serviceTemplate);
Assert.assertEquals("strimzi-cluster-operator.v0.25.0", serviceTemplate.getName());
}
use of org.jboss.tools.openshift.core.odo.ServiceTemplate in project jbosstools-openshift by jbosstools.
the class ServiceTemplateTest method verifyThatServiceTemplatesReturnsCRDs.
@Test
public void verifyThatServiceTemplatesReturnsCRDs() throws IOException {
List<ServiceTemplate> serviceTemplates = MAPPER.readValue(url, new TypeReference<List<ServiceTemplate>>() {
});
Assert.assertNotNull(serviceTemplates);
Assert.assertEquals(1, serviceTemplates.size());
ServiceTemplate serviceTemplate = serviceTemplates.get(0);
Assert.assertNotNull(serviceTemplate);
Assert.assertEquals("strimzi-cluster-operator.v0.25.0", serviceTemplate.getName());
assertTrue(serviceTemplate instanceof ServiceTemplate);
ServiceTemplate operatorServiceTemplate = (ServiceTemplate) serviceTemplate;
assertNotNull(operatorServiceTemplate.getCRDs());
assertEquals(9, operatorServiceTemplate.getCRDs().size());
}
Aggregations