Search in sources :

Example 1 with IBuildConfig

use of com.openshift.restclient.model.IBuildConfig 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;
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) ISelection(org.eclipse.jface.viewers.ISelection) Connection(org.jboss.tools.openshift.core.connection.Connection) Collection(java.util.Collection) ImportApplicationWizard(org.jboss.tools.openshift.internal.ui.wizard.importapp.ImportApplicationWizard) IProject(com.openshift.restclient.model.IProject) IResource(com.openshift.restclient.model.IResource)

Example 2 with IBuildConfig

use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.

the class ShowWebHooksHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    ISelection selection = UIUtils.getCurrentSelection(event);
    IBuildConfig buildConfig = UIUtils.getFirstElement(selection, IBuildConfig.class);
    if (buildConfig == null) {
        return Status.OK_STATUS;
    }
    WebHooksDialog dialog = new WebHooksDialog(HandlerUtil.getActiveShell(event), buildConfig);
    dialog.open();
    return Status.OK_STATUS;
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) WebHooksDialog(org.jboss.tools.openshift.internal.ui.webhooks.WebHooksDialog) ISelection(org.eclipse.jface.viewers.ISelection)

Example 3 with IBuildConfig

use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.

the class OpenshiftEapProfileDetectorTest method createBuildConfig.

@SuppressWarnings("deprecation")
private IBuildConfig createBuildConfig(Class<? extends IBuildStrategy> clazz, String name) {
    IBuildConfig bc = mock(IBuildConfig.class);
    DockerImageURI image = mock(DockerImageURI.class);
    when(image.getName()).thenReturn(name);
    IBuildStrategy strategy = null;
    if (clazz == null) {
        strategy = mock(ISourceBuildStrategy.class);
    } else if (IDockerBuildStrategy.class.isAssignableFrom(clazz)) {
        IDockerBuildStrategy dbs = mock(IDockerBuildStrategy.class);
        when(dbs.getBaseImage()).thenReturn(image);
        strategy = dbs;
    } else if (ICustomBuildStrategy.class.isAssignableFrom(clazz)) {
        ICustomBuildStrategy cbs = mock(ICustomBuildStrategy.class);
        when(cbs.getImage()).thenReturn(image);
        strategy = cbs;
    } else if (ISTIBuildStrategy.class.isAssignableFrom(clazz)) {
        ISTIBuildStrategy sts = mock(ISTIBuildStrategy.class);
        when(sts.getImage()).thenReturn(image);
        strategy = sts;
    } else if (ISourceBuildStrategy.class.isAssignableFrom(clazz)) {
        ISourceBuildStrategy sbs = mock(ISourceBuildStrategy.class);
        when(sbs.getImage()).thenReturn(image);
        strategy = sbs;
    }
    when(bc.getBuildStrategy()).thenReturn(strategy);
    Map<String, String> labels = Collections.singletonMap("template", name);
    when(bc.getLabels()).thenReturn(labels);
    return bc;
}
Also used : ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) DockerImageURI(com.openshift.restclient.images.DockerImageURI) IBuildConfig(com.openshift.restclient.model.IBuildConfig) IDockerBuildStrategy(com.openshift.restclient.model.build.IDockerBuildStrategy) IBuildStrategy(com.openshift.restclient.model.build.IBuildStrategy) ISTIBuildStrategy(com.openshift.restclient.model.build.ISTIBuildStrategy) ISTIBuildStrategy(com.openshift.restclient.model.build.ISTIBuildStrategy) ICustomBuildStrategy(com.openshift.restclient.model.build.ICustomBuildStrategy)

Example 4 with IBuildConfig

use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.

the class ResourceMocks method createBuildConfig.

public static IBuildConfig createBuildConfig(String name, IProject project, String buildOutputReferenceKind, String buildOutputReferenceName, String buildSourceURI, String contextDir, String ref, IBuildStrategy strategy) {
    IBuildConfig bc = mock(IBuildConfig.class);
    doReturn(ResourceKind.BUILD_CONFIG).when(bc).getKind();
    createBuildOutputReference(buildOutputReferenceKind, buildOutputReferenceName, bc);
    createGitBuildSource(contextDir, ref, bc);
    mockGetResourceProperties(name, project, bc);
    doReturn(buildSourceURI).when(bc).getSourceURI();
    doReturn(strategy).when(bc).getBuildStrategy();
    return bc;
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig)

Example 5 with IBuildConfig

use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.

the class ResourceDetailsContentProviderTest method shouldReturnResourcePropertyGivenBuildConfigBuildStrategyExists.

@Test
public void shouldReturnResourcePropertyGivenBuildConfigBuildStrategyExists() {
    // given
    IBuildConfig bc = createBuildConfig("42", null, null, null, null, null, null, createSourceBuildStrategy("42"));
    // when
    Object[] children = contentProvider.getChildren(bc);
    // then
    ResourceProperty property = getResourceProperty(ResourceDetailsContentProvider.LABEL_STRATEGY, children);
    assertThat(property).isNotNull();
    assertThat(property.isUnknownValue()).isFalse();
}
Also used : ResourceProperty(org.jboss.tools.openshift.internal.ui.wizard.newapp.ResourceDetailsContentProvider.ResourceProperty) IBuildConfig(com.openshift.restclient.model.IBuildConfig) Test(org.junit.Test)

Aggregations

IBuildConfig (com.openshift.restclient.model.IBuildConfig)29 Test (org.junit.Test)12 IService (com.openshift.restclient.model.IService)5 IResource (com.openshift.restclient.model.IResource)4 Collection (java.util.Collection)4 DockerImageURI (com.openshift.restclient.images.DockerImageURI)3 IProject (com.openshift.restclient.model.IProject)3 ISourceBuildStrategy (com.openshift.restclient.model.build.ISourceBuildStrategy)3 IRoute (com.openshift.restclient.model.route.IRoute)3 ResourceKind (com.openshift.restclient.ResourceKind)2 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)2 IBuildStrategy (com.openshift.restclient.model.build.IBuildStrategy)2 ICustomBuildStrategy (com.openshift.restclient.model.build.ICustomBuildStrategy)2 IDockerBuildStrategy (com.openshift.restclient.model.build.IDockerBuildStrategy)2 IWebhookTrigger (com.openshift.restclient.model.build.IWebhookTrigger)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 IStatus (org.eclipse.core.runtime.IStatus)2