Search in sources :

Example 1 with IBuild

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;
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IPod(com.openshift.restclient.model.IPod) IBuild(com.openshift.restclient.model.IBuild)

Example 2 with IBuild

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;
}
Also used : IResource(com.openshift.restclient.model.IResource) ResourceKind(com.openshift.restclient.ResourceKind) IBuildConfig(com.openshift.restclient.model.IBuildConfig) Collection(java.util.Collection) IBuild(com.openshift.restclient.model.IBuild) ResourceUtils(org.jboss.tools.openshift.internal.core.util.ResourceUtils) ResourceUtils.imageRef(org.jboss.tools.openshift.internal.core.util.ResourceUtils.imageRef) IDeploymentImageChangeTrigger(com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) HashSet(java.util.HashSet) IPod(com.openshift.restclient.model.IPod) OpenShiftAPIAnnotations(org.jboss.tools.openshift.core.OpenShiftAPIAnnotations) IRoute(com.openshift.restclient.model.route.IRoute) DeploymentTriggerType(com.openshift.restclient.model.deploy.DeploymentTriggerType) Collections(java.util.Collections) IReplicationController(com.openshift.restclient.model.IReplicationController) IService(com.openshift.restclient.model.IService) IBuild(com.openshift.restclient.model.IBuild) HashSet(java.util.HashSet)

Example 3 with IBuild

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());
}
Also used : IBuild(com.openshift.restclient.model.IBuild) Test(org.junit.Test)

Example 4 with IBuild

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));
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) IBuild(com.openshift.restclient.model.IBuild) Test(org.junit.Test)

Example 5 with IBuild

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();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IBuildTriggerable(com.openshift.restclient.capability.resources.IBuildTriggerable) OpenShiftException(com.openshift.restclient.OpenShiftException) IBuild(com.openshift.restclient.model.IBuild)

Aggregations

IBuild (com.openshift.restclient.model.IBuild)5 IPod (com.openshift.restclient.model.IPod)2 Test (org.junit.Test)2 OpenShiftException (com.openshift.restclient.OpenShiftException)1 ResourceKind (com.openshift.restclient.ResourceKind)1 IBuildTriggerable (com.openshift.restclient.capability.resources.IBuildTriggerable)1 DockerImageURI (com.openshift.restclient.images.DockerImageURI)1 IBuildConfig (com.openshift.restclient.model.IBuildConfig)1 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)1 IReplicationController (com.openshift.restclient.model.IReplicationController)1 IResource (com.openshift.restclient.model.IResource)1 IService (com.openshift.restclient.model.IService)1 DeploymentTriggerType (com.openshift.restclient.model.deploy.DeploymentTriggerType)1 IDeploymentImageChangeTrigger (com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger)1 IRoute (com.openshift.restclient.model.route.IRoute)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Collectors (java.util.stream.Collectors)1