public void pullImage(String imageName) { this.readWriteLock.readLock().lock(); try { final Image image = Image.valueOf(imageName); PullImageCmd pullImageCmd = this.dockerClient.pullImageCmd(image.getName()); String tag = image.getTag(); if (tag != null && !"".equals(tag)) { pullImageCmd.withTag(tag); } else { pullImageCmd.withTag("latest"); } pullImageCmd.exec(new PullImageResultCallback()).awaitSuccess(); } finally { this.readWriteLock.readLock().unlock(); } }
public void pullImage(String imageName) { this.readWriteLock.readLock().lock(); try { final Image image = Image.valueOf(imageName); PullImageCmd pullImageCmd = this.dockerClient.pullImageCmd(image.getName()); String tag = image.getTag(); if (tag != null && !"".equals(tag)) { pullImageCmd.withTag(tag); } else { pullImageCmd.withTag("latest"); } pullImageCmd.exec(new PullImageResultCallback()).awaitSuccess(); } finally { this.readWriteLock.readLock().unlock(); } }
@Test public void shouldParseSimpleImages() { final Image image = Image.valueOf("my_image"); assertThat(image.getName(), is("my_image")); assertThat(image.getTag(), is(nullValue())); }
@Test public void shouldParseRepositoryImages() { final Image image = Image.valueOf("localhost:5000/organization/my_image"); assertThat(image.getName(), is("localhost:5000/organization/my_image")); assertThat(image.getTag(), is(nullValue())); }
@Test public void shouldParseOrganizationImages() { final Image image = Image.valueOf("organization/my_image"); assertThat(image.getName(), is("organization/my_image")); assertThat(image.getTag(), is(nullValue())); }
@Test public void shouldParseRepositoryImagesAndSeveralOrganizationLevels() { final Image image = Image.valueOf("localhost:5000/organization/organization2/my_image"); assertThat(image.getName(), is("localhost:5000/organization/organization2/my_image")); assertThat(image.getTag(), is(nullValue())); }
@Test public void shouldParseSimpleImagesWithTag() { final Image image = Image.valueOf("my_image:tag"); assertThat(image.getName(), is("my_image")); assertThat(image.getTag(), is("tag")); }
@Test public void shouldParseOrganizationalImagesWithTag() { final Image image = Image.valueOf("organization/my_image:tag"); assertThat(image.getName(), is("organization/my_image")); assertThat(image.getTag(), is("tag")); }
@Test public void shouldParseRepositoryImagesWithTagAndSeveralOrganizationLevels() { final Image image = Image.valueOf("localhost:5000/organization/organization2/my_image:tag"); assertThat(image.getName(), is("localhost:5000/organization/organization2/my_image")); assertThat(image.getTag(), is("tag")); } }
@Test public void should_override_custom_cube_properties() throws IOException { File newFile = testFolder.newFile("config.yaml"); Files.write(Paths.get(newFile.toURI()), CONTENT.getBytes()); Map<String, String> parameters = new HashMap<String, String>(); parameters.put("serverVersion", "1.13"); parameters.put("serverUri", "http://localhost:25123"); parameters.put("dockerContainersFiles", newFile.toURI().toString()); parameters.put("definitionFormat", DefinitionFormat.CUBE.name()); parameters.put("cubeSpecificProperties", OVERRIDE_CUSTOM); CubeDockerConfiguration cubeConfiguration = CubeDockerConfiguration.fromMap(parameters, null); final DockerCompositions dockerContainersContent = cubeConfiguration.getDockerContainersContent(); final CubeContainer tomcat = dockerContainersContent.get("tomcat"); assertThat(tomcat, is(notNullValue())); assertThat(tomcat.getImage().getTag(), is("7.0")); assertThat(tomcat.getAwait().getStrategy(), is("polling")); assertThat(tomcat.getBeforeStop().size(), is(1)); }
@Test public void shouldParseRepositoryImagesWithTag() { final Image image = Image.valueOf("localhost:5000/organization/my_image:tag"); assertThat(image.getName(), is("localhost:5000/organization/my_image")); assertThat(image.getTag(), is("tag")); }
Assert.assertEquals("7.0", container.getImage().getTag());