use of com.blackducksoftware.integration.hub.imageinspector.name.ImageNameResolver in project hub-docker-inspector by blackducksoftware.
the class imageNameResolverTest method testNone.
@Test
public void testNone() {
final ImageNameResolver resolver = new ImageNameResolver("");
assertFalse(resolver.getNewImageRepo().isPresent());
assertFalse(resolver.getNewImageTag().isPresent());
}
use of com.blackducksoftware.integration.hub.imageinspector.name.ImageNameResolver in project hub-docker-inspector by blackducksoftware.
the class imageNameResolverTest method testRepoOnly.
@Test
public void testRepoOnly() {
final ImageNameResolver resolver = new ImageNameResolver("alpine");
assertTrue(resolver.getNewImageRepo().isPresent());
assertTrue(resolver.getNewImageTag().isPresent());
assertEquals("alpine", resolver.getNewImageRepo().get());
assertEquals("latest", resolver.getNewImageTag().get());
}
use of com.blackducksoftware.integration.hub.imageinspector.name.ImageNameResolver in project hub-docker-inspector by blackducksoftware.
the class DockerEnvImageInspector method initImageName.
private void initImageName() throws HubIntegrationException {
logger.debug(String.format("initImageName(): dockerImage: %s, dockerTar: %s", config.getDockerImage(), config.getDockerTar()));
final ImageNameResolver resolver = new ImageNameResolver(config.getDockerImage());
resolver.getNewImageRepo().ifPresent(repoName -> config.setDockerImageRepo(repoName));
resolver.getNewImageTag().ifPresent(tagName -> config.setDockerImageTag(tagName));
logger.debug(String.format("initImageName(): final: dockerImage: %s; dockerImageRepo: %s; dockerImageTag: %s", config.getDockerImage(), config.getDockerImageRepo(), config.getDockerImageTag()));
}
use of com.blackducksoftware.integration.hub.imageinspector.name.ImageNameResolver in project hub-docker-inspector by blackducksoftware.
the class DockerClientManager method getTarFileFromDockerImageById.
public File getTarFileFromDockerImageById(final String imageId) throws HubIntegrationException, IOException {
final File imageTarDirectory = new File(new File(programPaths.getHubDockerWorkingDirPath()), "tarDirectory");
final DockerClient dockerClient = hubDockerClient.getDockerClient();
final InspectImageCmd inspectImageCmd = dockerClient.inspectImageCmd(imageId);
final InspectImageResponse imageDetails = inspectImageCmd.exec();
final List<String> repoTags = imageDetails.getRepoTags();
if (repoTags.size() == 0) {
throw new HubIntegrationException(String.format("Unable to get image name:tag for image ID %s", imageId));
}
final ImageNameResolver resolver = new ImageNameResolver(repoTags.get(0));
final String imageName = resolver.getNewImageRepo().get();
final String tagName = resolver.getNewImageTag().get();
logger.info(String.format("Converted image ID %s to image name:tag %s:%s", imageId, imageName, tagName));
final File imageTarFile = saveImageToDir(imageTarDirectory, Names.getImageTarFilename(imageName, tagName), imageName, tagName);
return imageTarFile;
}
use of com.blackducksoftware.integration.hub.imageinspector.name.ImageNameResolver in project hub-docker-inspector by blackducksoftware.
the class imageNameResolverTest method testBoth.
@Test
public void testBoth() {
final ImageNameResolver resolver = new ImageNameResolver("alpine:1.0");
assertTrue(resolver.getNewImageRepo().isPresent());
assertTrue(resolver.getNewImageTag().isPresent());
assertEquals("alpine", resolver.getNewImageRepo().get());
assertEquals("1.0", resolver.getNewImageTag().get());
}
Aggregations