Search in sources :

Example 1 with IBuildStrategy

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

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

the class ResourceDetailsContentProvider method addBuildConfigProperties.

private void addBuildConfigProperties(Collection<ResourceProperty> properties, IBuildConfig config) {
    IBuildStrategy buildStrategy = config.getBuildStrategy();
    addStrategyTypeProperties(properties, buildStrategy);
    properties.add(new ResourceProperty("source URL", config.getSourceURI()));
    properties.add(new ResourceProperty("output to", config.getOutputRepositoryName()));
    List<String> triggers = config.getBuildTriggers().stream().map(trigger -> trigger.getType().toString()).collect(Collectors.toList());
    properties.add(new ResourceProperty("build triggers", triggers));
}
Also used : IBuildStrategy(com.openshift.restclient.model.build.IBuildStrategy) IResource(com.openshift.restclient.model.IResource) Viewer(org.eclipse.jface.viewers.Viewer) ResourceKind(com.openshift.restclient.ResourceKind) IBuildConfig(com.openshift.restclient.model.IBuildConfig) BuildStrategyType(com.openshift.restclient.model.build.BuildStrategyType) Collection(java.util.Collection) StringUtils(org.jboss.tools.openshift.common.core.utils.StringUtils) IImageStream(com.openshift.restclient.model.IImageStream) ResourceKindAndNameComparator(org.jboss.tools.openshift.internal.core.util.ResourceKindAndNameComparator) IDockerBuildStrategy(com.openshift.restclient.model.build.IDockerBuildStrategy) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) List(java.util.List) IJenkinsPipelineStrategy(com.openshift.restclient.model.build.IJenkinsPipelineStrategy) IRoute(com.openshift.restclient.model.route.IRoute) ICustomBuildStrategy(com.openshift.restclient.model.build.ICustomBuildStrategy) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) Collections(java.util.Collections) IService(com.openshift.restclient.model.IService) IBuildStrategy(com.openshift.restclient.model.build.IBuildStrategy)

Example 3 with IBuildStrategy

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

IBuildStrategy (com.openshift.restclient.model.build.IBuildStrategy)3 ICustomBuildStrategy (com.openshift.restclient.model.build.ICustomBuildStrategy)3 IDockerBuildStrategy (com.openshift.restclient.model.build.IDockerBuildStrategy)3 ISourceBuildStrategy (com.openshift.restclient.model.build.ISourceBuildStrategy)3 DockerImageURI (com.openshift.restclient.images.DockerImageURI)2 IBuildConfig (com.openshift.restclient.model.IBuildConfig)2 ISTIBuildStrategy (com.openshift.restclient.model.build.ISTIBuildStrategy)2 ResourceKind (com.openshift.restclient.ResourceKind)1 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)1 IImageStream (com.openshift.restclient.model.IImageStream)1 IResource (com.openshift.restclient.model.IResource)1 IService (com.openshift.restclient.model.IService)1 BuildStrategyType (com.openshift.restclient.model.build.BuildStrategyType)1 IJenkinsPipelineStrategy (com.openshift.restclient.model.build.IJenkinsPipelineStrategy)1 IRoute (com.openshift.restclient.model.route.IRoute)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1