Search in sources :

Example 1 with ISourceBuildStrategy

use of com.openshift.restclient.model.build.ISourceBuildStrategy 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 2 with ISourceBuildStrategy

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

the class ResourceMocks method createSourceBuildStrategy.

public static IBuildStrategy createSourceBuildStrategy(String uri) {
    DockerImageURI dockerUri = mock(DockerImageURI.class);
    doReturn(uri).when(dockerUri).getAbsoluteUri();
    ISourceBuildStrategy strategy = mock(ISourceBuildStrategy.class);
    doReturn(BuildStrategyType.SOURCE).when(strategy).getType();
    doReturn(dockerUri).when(strategy).getImage();
    return strategy;
}
Also used : ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) DockerImageURI(com.openshift.restclient.images.DockerImageURI)

Example 3 with ISourceBuildStrategy

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

the class ServerSettingsWizardPageModelTest method testGetEapOpenshiftProfile.

@Test
public void testGetEapOpenshiftProfile() {
    DockerImageURI image = mock(DockerImageURI.class);
    when(image.getName()).thenReturn("super-puper-eap-name");
    ISourceBuildStrategy buildStrategy = mock(ISourceBuildStrategy.class);
    when(buildStrategy.getImage()).thenReturn(image);
    IBuildConfig buildConfig = (IBuildConfig) connection.getResources(ResourceKind.BUILD_CONFIG, ResourceMocks.PROJECT2.getName()).get(1);
    when(buildConfig.getBuildStrategy()).thenReturn(buildStrategy);
    assertEquals("openshift3.eap", this.model.getProfileId());
}
Also used : ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) DockerImageURI(com.openshift.restclient.images.DockerImageURI) IBuildConfig(com.openshift.restclient.model.IBuildConfig) Test(org.junit.Test)

Example 4 with ISourceBuildStrategy

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

the class BuildConfigPropertySourceTest method getSTIPropertyValues.

@Test
public void getSTIPropertyValues() {
    ISourceBuildStrategy strategy = givenSTIBuildStrategy();
    assertEquals(BuildStrategyType.SOURCE, source.getPropertyValue(BuildConfigPropertySource.Ids.Type));
    assertEquals(strategy.getScriptsLocation(), source.getPropertyValue(BuildConfigPropertySource.Ids.STI_SCRIPT_LOCATION));
    assertEquals(strategy.getImage(), source.getPropertyValue(BuildConfigPropertySource.Ids.STI_IMAGE));
    assertEquals(new KeyValuePropertySource(strategy.getEnvironmentVariables()), source.getPropertyValue(BuildConfigPropertySource.Ids.STI_ENV));
}
Also used : ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) KeyValuePropertySource(org.jboss.tools.openshift.internal.ui.property.KeyValuePropertySource) Test(org.junit.Test)

Example 5 with ISourceBuildStrategy

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

the class ResourceDetailsContentProvider method addStrategyTypeProperties.

private void addStrategyTypeProperties(Collection<ResourceProperty> properties, IBuildStrategy buildStrategy) {
    if (buildStrategy == null || buildStrategy.getType() == null) {
        properties.add(new UnknownResourceProperty(LABEL_STRATEGY));
        return;
    }
    properties.add(new ResourceProperty(LABEL_STRATEGY, buildStrategy.getType().toString()));
    switch(buildStrategy.getType()) {
        case BuildStrategyType.SOURCE:
            ISourceBuildStrategy sti = (ISourceBuildStrategy) buildStrategy;
            properties.add(new ResourceProperty("builder image", StringUtils.toStringOrNull(sti.getImage())));
            break;
        case BuildStrategyType.DOCKER:
            IDockerBuildStrategy docker = (IDockerBuildStrategy) buildStrategy;
            properties.add(new ResourceProperty("base image", StringUtils.toStringOrNull(docker.getBaseImage())));
            break;
        case BuildStrategyType.CUSTOM:
            ICustomBuildStrategy custom = (ICustomBuildStrategy) buildStrategy;
            properties.add(new ResourceProperty("builder image", StringUtils.toStringOrNull(custom.getImage())));
            break;
        case BuildStrategyType.JENKINS_PIPELINE:
            IJenkinsPipelineStrategy jenkins = (IJenkinsPipelineStrategy) buildStrategy;
            properties.add(new ResourceProperty("jenkins file", StringUtils.removeAll(StringUtils.getLineSeparator(), jenkins.getJenkinsfile())));
            properties.add(new ResourceProperty("jenkins file path", StringUtils.toStringOrNull(jenkins.getJenkinsfilePath())));
            break;
        default:
    }
}
Also used : ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) IDockerBuildStrategy(com.openshift.restclient.model.build.IDockerBuildStrategy) ICustomBuildStrategy(com.openshift.restclient.model.build.ICustomBuildStrategy) IJenkinsPipelineStrategy(com.openshift.restclient.model.build.IJenkinsPipelineStrategy)

Aggregations

ISourceBuildStrategy (com.openshift.restclient.model.build.ISourceBuildStrategy)7 DockerImageURI (com.openshift.restclient.images.DockerImageURI)5 ICustomBuildStrategy (com.openshift.restclient.model.build.ICustomBuildStrategy)3 IDockerBuildStrategy (com.openshift.restclient.model.build.IDockerBuildStrategy)3 IBuildConfig (com.openshift.restclient.model.IBuildConfig)2 IBuildStrategy (com.openshift.restclient.model.build.IBuildStrategy)2 ISTIBuildStrategy (com.openshift.restclient.model.build.ISTIBuildStrategy)2 Test (org.junit.Test)2 IJenkinsPipelineStrategy (com.openshift.restclient.model.build.IJenkinsPipelineStrategy)1 HashMap (java.util.HashMap)1 KeyValuePropertySource (org.jboss.tools.openshift.internal.ui.property.KeyValuePropertySource)1