use of com.synopsys.integration.blackduck.imageinspector.image.common.RepoTag in project blackduck-docker-inspector by blackducksoftware.
the class DockerInspector method initImageName.
private void initImageName() {
logger.debug(String.format("initImageName(): dockerImage: %s, dockerTar: %s", config.getDockerImage(), config.getDockerTar()));
ImageNameResolver resolver = new ImageNameResolver();
RepoTag resolvedRepoTag = resolver.resolve(config.getDockerImage(), null, null);
if (resolvedRepoTag.getRepo().isPresent()) {
config.setDockerImageRepo(resolvedRepoTag.getRepo().get());
}
if (resolvedRepoTag.getTag().isPresent()) {
config.setDockerImageTag(resolvedRepoTag.getTag().get());
}
logger.debug(String.format("initImageName(): final: dockerImage: %s; dockerImageRepo: %s; dockerImageTag: %s", config.getDockerImage(), config.getDockerImageRepo(), config.getDockerImageTag()));
}
use of com.synopsys.integration.blackduck.imageinspector.image.common.RepoTag 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);
}
Aggregations