use of com.openshift.restclient.model.IBuild in project jbosstools-openshift by jbosstools.
the class PodLogsHandler method getPodFromBuild.
private IPod getPodFromBuild(ExecutionEvent event) {
IBuild build = getSelectedElement(event, IBuild.class);
if (build != null) {
final String buildName = build.getName();
Connection connection = ConnectionsRegistryUtil.safeGetConnectionFor(build);
List<IPod> pods = connection.getResources(ResourceKind.POD, build.getNamespaceName());
for (IPod pod : pods) {
if (buildName.equals(pod.getAnnotation(OpenShiftAPIAnnotations.BUILD_NAME))) {
return pod;
}
}
}
return null;
}
use of com.openshift.restclient.model.IBuild in project jbosstools-openshift by jbosstools.
the class ServiceResourceMapper method getRelatedBuilds.
private static Collection<IBuild> getRelatedBuilds(Collection<IResource> resources, Collection<String> dcImageRefs, Collection<IBuildConfig> buildConfigs) {
Collection<IBuild> result = new HashSet<>();
Collection<String> bcNames = buildConfigs.stream().map(bc -> bc.getName()).collect(Collectors.toSet());
resources.forEach(r -> {
if (r instanceof IBuild) {
IBuild build = (IBuild) r;
if (bcNames.contains(r.getLabels().get(OpenShiftAPIAnnotations.BUILD_CONFIG_NAME)) || dcImageRefs.contains(imageRef(build))) {
result.add((IBuild) r);
}
}
});
return result;
}
use of com.openshift.restclient.model.IBuild in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerLabelProviderTest method getStyledTextForABuild.
@Test
public void getStyledTextForABuild() {
IBuild build = givenAResource(IBuild.class, ResourceKind.BUILD);
when(build.getStatus()).thenReturn("Running");
assertEquals(String.format("%s Build Running", build.getName()), provider.getStyledText(build).getString());
}
use of com.openshift.restclient.model.IBuild in project jbosstools-openshift by jbosstools.
the class ResourceUtilsTest method testImageRefForBuild.
@Test
public void testImageRefForBuild() {
assertEquals("", imageRef((IBuild) null));
when(build.getOutputKind()).thenReturn("something");
assertEquals("", imageRef(build));
DockerImageURI uri = new DockerImageURI(IMAGE_REF);
when(build.getOutputTo()).thenReturn(uri);
when(build.getOutputKind()).thenReturn(ResourceKind.IMAGE_STREAM_TAG);
assertEquals(IMAGE_REF, imageRef(build));
when(build.getOutputKind()).thenReturn(ResourceUtils.IMAGE_STREAM_IMAGE_KIND);
assertEquals(IMAGE_REF, imageRef(build));
when(build.getOutputKind()).thenReturn(ResourceUtils.DOCKER_IMAGE_KIND);
assertEquals(IMAGE_REF, imageRef(build));
}
use of com.openshift.restclient.model.IBuild in project jbosstools-openshift by jbosstools.
the class StartBuildJob method doRun.
@Override
protected IStatus doRun(IProgressMonitor monitor) {
try {
monitor.beginTask("Starting build job", IProgressMonitor.UNKNOWN);
IBuild build = buildsource.accept(new CapabilityVisitor<IBuildTriggerable, IBuild>() {
@Override
public IBuild visit(IBuildTriggerable triggerable) {
return triggerable.trigger();
}
}, null);
if (build == null) {
return new Status(Status.INFO, OpenShiftUIActivator.PLUGIN_ID, "Manually triggering builds is unsupported");
}
return Status.OK_STATUS;
} catch (OpenShiftException e) {
return new Status(Status.ERROR, OpenShiftUIActivator.PLUGIN_ID, NLS.bind("Error starting build {0}.", buildsource.getName()), e);
} finally {
monitor.done();
}
}
Aggregations