Search in sources :

Example 6 with ISourceBuildStrategy

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

the class BuildConfigPropertySourceTest method givenSTIBuildStrategy.

private ISourceBuildStrategy givenSTIBuildStrategy() {
    ISourceBuildStrategy strategy = mock(ISourceBuildStrategy.class);
    when(strategy.getType()).thenReturn(BuildStrategyType.SOURCE);
    when(strategy.getScriptsLocation()).thenReturn("scriptlocation");
    when(strategy.getImage()).thenReturn(new DockerImageURI("foobar"));
    Map<String, String> env = new HashMap<>();
    env.put("foo", "bar");
    when(strategy.getEnvironmentVariables()).thenReturn(env);
    when(resource.getBuildStrategy()).thenReturn(strategy);
    return strategy;
}
Also used : ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) DockerImageURI(com.openshift.restclient.images.DockerImageURI) HashMap(java.util.HashMap)

Example 7 with ISourceBuildStrategy

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

the class OpenshiftEapProfileDetector method isEapStyle.

@SuppressWarnings({ "deprecation" })
public boolean isEapStyle(IBuildConfig buildConfig) {
    if (buildConfig == null) {
        return false;
    }
    // First check buildconfig docker image name
    IBuildStrategy strategy = buildConfig.getBuildStrategy();
    DockerImageURI image = null;
    boolean isEapStyle = false;
    if (strategy instanceof ISourceBuildStrategy) {
        image = ((ISourceBuildStrategy) strategy).getImage();
    } else if (strategy instanceof ICustomBuildStrategy) {
        image = ((ICustomBuildStrategy) strategy).getImage();
    } else if (strategy instanceof IDockerBuildStrategy) {
        image = ((IDockerBuildStrategy) strategy).getBaseImage();
    } else if (strategy instanceof ISTIBuildStrategy) {
        image = ((ISTIBuildStrategy) strategy).getImage();
    }
    if (image != null) {
        isEapStyle = containsEapLikeKeywords(image.getName());
    }
    if (!isEapStyle) {
        // Check template labels as a last resort
        // not sure it's even possible to reach this point
        Map<String, String> labels = buildConfig.getLabels();
        if (labels != null) {
            String template = labels.get("template");
            isEapStyle = containsEapLikeKeywords(template);
        }
    }
    return isEapStyle;
}
Also used : ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) DockerImageURI(com.openshift.restclient.images.DockerImageURI) 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)

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