Search in sources :

Example 6 with IImageStream

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

the class OpenShiftExplorerLabelProviderTest method getStyledTextForAnImageRepository.

@Test
public void getStyledTextForAnImageRepository() {
    IImageStream repo = givenAResource(IImageStream.class, ResourceKind.IMAGE_STREAM);
    when(repo.getDockerImageRepository()).thenReturn(new DockerImageURI("127.0.0.1", "foo", "bar"));
    assertEquals(repo.getName() + " " + repo.getDockerImageRepository(), provider.getStyledText(repo).getString());
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) IImageStream(com.openshift.restclient.model.IImageStream) Test(org.junit.Test)

Example 7 with IImageStream

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

the class DeployImageJobTest method testStubImageStreamWhereOneDoesNotExistAndImageIsPublic.

@Test
public void testStubImageStreamWhereOneDoesNotExistAndImageIsPublic() {
    givenAnImageStreamTo("foo", null);
    givenTheImageIsVisible(true);
    IImageStream is = whenStubbingTheImageStream();
    assertNotNull("Exp. an IS to be returned", is);
    assertEquals(RESOURCE_NAME, is.getName());
    assertEquals(project.getName(), is.getNamespaceName());
    assertEquals(1, is.getTags().size());
    assertEquals(DOCKER_TAG.toString(), is.getTags().iterator().next().getFrom().getName());
}
Also used : IImageStream(com.openshift.restclient.model.IImageStream) Test(org.junit.Test)

Example 8 with IImageStream

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

the class NewApplicationWizardModelTest method setDefaultAppLabelForImageBasedApplications.

@Test
public void setDefaultAppLabelForImageBasedApplications() {
    // pre-conditions
    IApplicationSource source = mock(IApplicationSource.class);
    when(source.getKind()).thenReturn(ResourceKind.IMAGE_STREAM);
    IImageStream imageStream = mock(IImageStream.class);
    when(source.getSource()).thenReturn(imageStream);
    when(imageStream.getName()).thenReturn("my-image-stream");
    // operations
    model.setServerAppSource(source);
    // verification
    verify(model, Mockito.times(1)).setLabels(Arrays.asList(new Label("app", "my-image-stream")));
}
Also used : IApplicationSource(org.jboss.tools.openshift.internal.ui.wizard.newapp.IApplicationSource) Label(org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label) IImageStream(com.openshift.restclient.model.IImageStream) Test(org.junit.Test)

Example 9 with IImageStream

use of com.openshift.restclient.model.IImageStream 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)

Example 10 with IImageStream

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

the class DeployImageJobTest method givenAnImageStreamTo.

private IImageStream givenAnImageStreamTo(String namespace, DockerImageURI uri) {
    IImageStream is = mock(IImageStream.class);
    when(is.getNamespaceName()).thenReturn(namespace);
    when(is.getName()).thenReturn(IMAGE_STREAM_NAME);
    when(is.getDockerImageRepository()).thenReturn(uri);
    List<IResource> streams = Arrays.asList(is);
    Connection conn = mock(Connection.class);
    when(conn.getResources(anyString(), eq(namespace))).thenReturn(streams);
    when(conn.getClusterNamespace()).thenReturn(ICommonAttributes.COMMON_NAMESPACE);
    when(parameters.getConnection()).thenReturn(conn);
    return is;
}
Also used : ResourceMocks.createConnection(org.jboss.tools.openshift.test.util.ResourceMocks.createConnection) Connection(org.jboss.tools.openshift.core.connection.Connection) IImageStream(com.openshift.restclient.model.IImageStream) IResource(com.openshift.restclient.model.IResource)

Aggregations

IImageStream (com.openshift.restclient.model.IImageStream)13 Test (org.junit.Test)8 DockerImageURI (com.openshift.restclient.images.DockerImageURI)4 IProject (com.openshift.restclient.model.IProject)3 IResource (com.openshift.restclient.model.IResource)3 Connection (org.jboss.tools.openshift.core.connection.Connection)3 IResourceFactory (com.openshift.restclient.IResourceFactory)2 ResourceKind (com.openshift.restclient.ResourceKind)2 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)2 IDeploymentImageChangeTrigger (com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 List (java.util.List)2 IStatus (org.eclipse.core.runtime.IStatus)2 ICommonAttributes (org.jboss.tools.openshift.core.ICommonAttributes)2 ResourceMocks.createConnection (org.jboss.tools.openshift.test.util.ResourceMocks.createConnection)2 ResourceFactory (com.openshift.internal.restclient.ResourceFactory)1 IClient (com.openshift.restclient.IClient)1 OpenShiftException (com.openshift.restclient.OpenShiftException)1