Search in sources :

Example 1 with ImageStreamApplicationSource

use of org.jboss.tools.openshift.internal.ui.wizard.newapp.fromimage.ImageStreamApplicationSource in project jbosstools-openshift by jbosstools.

the class ApplicationSourceTreeItems method loadImageStreams.

private Collection<IApplicationSource> loadImageStreams(IProject project, Connection conn) {
    final Collection<IImageStream> streams = conn.getResources(ResourceKind.IMAGE_STREAM, project.getNamespaceName());
    try {
        if (StringUtils.isNotBlank(conn.getClusterNamespace())) {
            Collection<IImageStream> commonStreams = conn.getResources(ResourceKind.IMAGE_STREAM, (String) conn.getClusterNamespace());
            commonStreams.stream().filter(s -> !streams.contains(s)).forEach(s -> streams.add(s));
        }
    } catch (OpenShiftException e) {
        OpenShiftUIActivator.log(IStatus.ERROR, e.getLocalizedMessage(), e);
    }
    Collection<IApplicationSource> sources = new ArrayList<>();
    for (IImageStream is : streams) {
        List<ITagReference> tags = is.getTags().stream().filter(t -> t.isAnnotatedWith(OpenShiftAPIAnnotations.TAGS) && ArrayUtils.contains(t.getAnnotation(OpenShiftAPIAnnotations.TAGS).split(","), BUILDER_TAG)).collect(Collectors.toList());
        if (!tags.isEmpty()) {
            tags.forEach(t -> sources.add(new ImageStreamApplicationSource(is, t)));
        }
    }
    return sources;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) IImageStream(com.openshift.restclient.model.IImageStream) OpenShiftException(com.openshift.restclient.OpenShiftException) TemplateApplicationSource(org.jboss.tools.openshift.internal.ui.wizard.newapp.fromtemplate.TemplateApplicationSource) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) IProject(com.openshift.restclient.model.IProject) ArrayList(java.util.ArrayList) IStatus(org.eclipse.core.runtime.IStatus) IModelFactory(org.jboss.tools.openshift.internal.ui.treeitem.IModelFactory) OpenShiftUIActivator(org.jboss.tools.openshift.internal.ui.OpenShiftUIActivator) ResourceKind(com.openshift.restclient.ResourceKind) ITagReference(com.openshift.restclient.model.image.ITagReference) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) Connection(org.jboss.tools.openshift.core.connection.Connection) List(java.util.List) ICommonAttributes(org.jboss.tools.openshift.core.ICommonAttributes) OpenShiftAPIAnnotations(org.jboss.tools.openshift.core.OpenShiftAPIAnnotations) CapabilityVisitor(com.openshift.restclient.capability.CapabilityVisitor) ConnectionsRegistryUtil(org.jboss.tools.openshift.core.connection.ConnectionsRegistryUtil) IProjectTemplateList(com.openshift.restclient.capability.resources.IProjectTemplateList) ITemplate(com.openshift.restclient.model.template.ITemplate) ImageStreamApplicationSource(org.jboss.tools.openshift.internal.ui.wizard.newapp.fromimage.ImageStreamApplicationSource) Collections(java.util.Collections) ArrayUtils(org.apache.commons.lang.ArrayUtils) ITagReference(com.openshift.restclient.model.image.ITagReference) OpenShiftException(com.openshift.restclient.OpenShiftException) ArrayList(java.util.ArrayList) IImageStream(com.openshift.restclient.model.IImageStream) ImageStreamApplicationSource(org.jboss.tools.openshift.internal.ui.wizard.newapp.fromimage.ImageStreamApplicationSource)

Aggregations

OpenShiftException (com.openshift.restclient.OpenShiftException)1 ResourceKind (com.openshift.restclient.ResourceKind)1 CapabilityVisitor (com.openshift.restclient.capability.CapabilityVisitor)1 IProjectTemplateList (com.openshift.restclient.capability.resources.IProjectTemplateList)1 IImageStream (com.openshift.restclient.model.IImageStream)1 IProject (com.openshift.restclient.model.IProject)1 ITagReference (com.openshift.restclient.model.image.ITagReference)1 ITemplate (com.openshift.restclient.model.template.ITemplate)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 ArrayUtils (org.apache.commons.lang.ArrayUtils)1 StringUtils (org.apache.commons.lang.StringUtils)1 IStatus (org.eclipse.core.runtime.IStatus)1 ICommonAttributes (org.jboss.tools.openshift.core.ICommonAttributes)1 OpenShiftAPIAnnotations (org.jboss.tools.openshift.core.OpenShiftAPIAnnotations)1 Connection (org.jboss.tools.openshift.core.connection.Connection)1 ConnectionsRegistryUtil (org.jboss.tools.openshift.core.connection.ConnectionsRegistryUtil)1