Search in sources :

Example 26 with DockerImageURI

use of com.openshift.restclient.images.DockerImageURI in project jbosstools-openshift by jbosstools.

the class DeployImageJobTest method shouldUpdateImageTagIfItDifferesFromExisting.

@Test
public void shouldUpdateImageTagIfItDifferesFromExisting() {
    givenAConnection();
    givenTheImageStreamExistsTo("myimagename");
    givenTheDeploymentConfigExistFor("myimagename", "v0", NAMESPACE, ResourceKind.IMAGE_STREAM_TAG);
    doReturn(DOCKER_NEW_TAG).when(job).getSourceImage();
    IResource resource = connection.getResource(ResourceKind.DEPLOYMENT_CONFIG, project.getName(), parameters.getResourceName());
    IDeploymentImageChangeTrigger trigger = (IDeploymentImageChangeTrigger) ((IDeploymentConfig) resource).getTriggers().toArray()[0];
    assertThat(job.doRun(monitor)).isEqualTo(Status.OK_STATUS);
    verify(trigger, times(1)).setFrom(new DockerImageURI(null, null, "myimagename", "v1"));
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) IDeploymentImageChangeTrigger(com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger) IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

Example 27 with DockerImageURI

use of com.openshift.restclient.images.DockerImageURI in project jbosstools-openshift by jbosstools.

the class ResourceUtilsTest method testImageRefForDeploymentImageChangeTrigger.

@Test
public void testImageRefForDeploymentImageChangeTrigger() {
    assertEquals("", imageRef((IDeploymentImageChangeTrigger) null));
    when(deployTrigger.getKind()).thenReturn("something");
    assertEquals("", imageRef(deployTrigger));
    DockerImageURI uri = new DockerImageURI(IMAGE_REF);
    when(deployTrigger.getFrom()).thenReturn(uri);
    when(deployTrigger.getKind()).thenReturn(ResourceKind.IMAGE_STREAM_TAG);
    assertEquals(IMAGE_REF, imageRef(deployTrigger));
    when(deployTrigger.getKind()).thenReturn(ResourceUtils.IMAGE_STREAM_IMAGE_KIND);
    assertEquals(IMAGE_REF, imageRef(deployTrigger));
    when(deployTrigger.getKind()).thenReturn(ResourceUtils.DOCKER_IMAGE_KIND);
    assertEquals(IMAGE_REF, imageRef(deployTrigger));
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) IDeploymentImageChangeTrigger(com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger) Test(org.junit.Test)

Example 28 with DockerImageURI

use of com.openshift.restclient.images.DockerImageURI in project jbosstools-openshift by jbosstools.

the class DockerImageLabels method importImageStream.

private String importImageStream(String imageRef, IProject project) {
    IImageStreamImportCapability imageStreamImportCapability = project.getCapability(IImageStreamImportCapability.class);
    DockerImageURI uri = new DockerImageURI(imageRef);
    IImageStreamImport imageStreamImport = imageStreamImportCapability.importImageMetadata(uri);
    if (!ResourceUtils.isSuccessful(imageStreamImport)) {
        return null;
    }
    return imageStreamImport.getImageJsonFor(uri);
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) IImageStreamImport(com.openshift.restclient.model.image.IImageStreamImport) IImageStreamImportCapability(com.openshift.restclient.capability.resources.IImageStreamImportCapability)

Example 29 with DockerImageURI

use of com.openshift.restclient.images.DockerImageURI in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModel method setImageName.

@Override
public void setImageName(final String imageName) {
    if (StringUtils.isBlank(imageName)) {
        return;
    }
    if (this.imageName != null && !this.imageName.equals(imageName) && this.imageMeta != null) {
        // Clean container info loaded for old image name.
        this.imageMeta = null;
        setEnvironmentVariables(new ArrayList<>());
        setPortSpecs(new ArrayList<>());
        setVolumes(new ArrayList<>());
    }
    firePropertyChange(PROPERTY_IMAGE_NAME, this.imageName, this.imageName = imageName);
    final DockerImageURI uri = new DockerImageURI(imageName);
    setResourceName(dockerImage2OpenshiftResourceConverter.convert(uri));
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI)

Example 30 with DockerImageURI

use of com.openshift.restclient.images.DockerImageURI in project jbosstools-openshift by jbosstools.

the class DockerImage2OpenshiftResourceConverterTest method testDoubleDash.

@Test
public void testDoubleDash() {
    String resourceName = converter.convert(new DockerImageURI("image--sub"));
    assertEquals("image-sub", resourceName);
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) Test(org.junit.Test)

Aggregations

DockerImageURI (com.openshift.restclient.images.DockerImageURI)39 Test (org.junit.Test)23 IDeploymentImageChangeTrigger (com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger)9 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)6 IImageStream (com.openshift.restclient.model.IImageStream)5 ISourceBuildStrategy (com.openshift.restclient.model.build.ISourceBuildStrategy)5 IImageStreamImportCapability (com.openshift.restclient.capability.resources.IImageStreamImportCapability)4 IResource (com.openshift.restclient.model.IResource)4 IImageStreamImport (com.openshift.restclient.model.image.IImageStreamImport)4 HashMap (java.util.HashMap)4 IResourceFactory (com.openshift.restclient.IResourceFactory)3 IBuildConfig (com.openshift.restclient.model.IBuildConfig)3 IProject (com.openshift.restclient.model.IProject)3 IStatus (com.openshift.restclient.model.IStatus)3 ICustomBuildStrategy (com.openshift.restclient.model.build.ICustomBuildStrategy)3 IDockerBuildStrategy (com.openshift.restclient.model.build.IDockerBuildStrategy)3 Collection (java.util.Collection)3 EnvironmentVariable (org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariable)3 ResourceKind (com.openshift.restclient.ResourceKind)2 IBuildStrategy (com.openshift.restclient.model.build.IBuildStrategy)2