use of com.synopsys.integration.blackduck.dockerinspector.output.ImageTarWrapper in project blackduck-docker-inspector by blackducksoftware.
the class DockerClientManager method getTarFileFromDockerImageById.
public ImageTarWrapper getTarFileFromDockerImageById(String imageId, File imageTarDirectory) throws IntegrationException, IOException {
InspectImageCmd inspectImageCmd = dockerClient.inspectImageCmd(imageId);
InspectImageResponse imageDetails = inspectImageCmd.exec();
List<String> repoTags = imageDetails.getRepoTags();
if (repoTags == null || repoTags.isEmpty()) {
throw new IntegrationException(String.format("Unable to get image name:tag for image ID %s", imageId));
}
RepoTag resolvedRepoTag = imageNameResolver.resolve(repoTags.get(0), null, null);
String imageName = resolvedRepoTag.getRepo().orElse("");
String tagName = resolvedRepoTag.getTag().orElse("");
logger.debug(String.format("Converted image ID %s to image name:tag %s:%s", imageId, imageName, tagName));
File imageTarFile = saveImageToDir(imageTarDirectory, imageTarFilename.deriveImageTarFilenameFromImageTag(imageName, tagName), imageName, tagName);
return new ImageTarWrapper(imageTarFile, imageName, tagName);
}
use of com.synopsys.integration.blackduck.dockerinspector.output.ImageTarWrapper in project blackduck-docker-inspector by blackducksoftware.
the class DockerClientManagerTest method testDeriveDockerTarfileFromConfiguredTar.
@Test
public void testDeriveDockerTarfileFromConfiguredTar() throws IOException, IntegrationException {
Mockito.when(programPaths.getDockerInspectorTargetDirPath()).thenReturn("test/containerShared/target");
Mockito.when(config.getDockerTar()).thenReturn("build/images/test/alpine.tar");
ImageTarWrapper imageTarWrapper = dockerClientManager.deriveDockerTarFileFromConfig();
assertEquals("alpine.tar", imageTarWrapper.getFile().getName());
}
use of com.synopsys.integration.blackduck.dockerinspector.output.ImageTarWrapper in project blackduck-docker-inspector by blackducksoftware.
the class DockerClientManagerTest method testDeriveDockerTarfileFromConfiguredImage.
@Test
public void testDeriveDockerTarfileFromConfiguredImage() throws IOException, IntegrationException {
Mockito.when(programPaths.getDockerInspectorTargetDirPath()).thenReturn("test/containerShared/target");
Mockito.when(config.getDockerImageRepo()).thenReturn("alpine");
Mockito.when(config.getDockerImageTag()).thenReturn("latest");
ImageTarWrapper imageTarWrapper = dockerClientManager.deriveDockerTarFileFromConfig();
assertEquals("alpine_latest.tar", imageTarWrapper.getFile().getName());
}
use of com.synopsys.integration.blackduck.dockerinspector.output.ImageTarWrapper in project blackduck-docker-inspector by blackducksoftware.
the class HttpClientInspector method prepareDockerTarfile.
private ImageTarWrapper prepareDockerTarfile(ImageInspectorClient imageInspectorClient) throws IOException, IntegrationException {
ImageTarWrapper givenDockerTarfile = dockerClientManager.deriveDockerTarFileFromConfig();
ImageTarWrapper finalDockerTarfile = imageInspectorClient.copyTarfileToSharedDir(fileOperations, config, programPaths, givenDockerTarfile);
return finalDockerTarfile;
}
Aggregations