Search in sources :

Example 1 with RepoTag

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()));
}
Also used : ImageNameResolver(com.synopsys.integration.blackduck.imageinspector.api.name.ImageNameResolver) RepoTag(com.synopsys.integration.blackduck.imageinspector.image.common.RepoTag)

Example 2 with RepoTag

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);
}
Also used : InspectImageCmd(com.github.dockerjava.api.command.InspectImageCmd) ImageTarWrapper(com.synopsys.integration.blackduck.dockerinspector.output.ImageTarWrapper) IntegrationException(com.synopsys.integration.exception.IntegrationException) BlackDuckIntegrationException(com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException) InspectImageResponse(com.github.dockerjava.api.command.InspectImageResponse) File(java.io.File) RepoTag(com.synopsys.integration.blackduck.imageinspector.image.common.RepoTag)

Aggregations

RepoTag (com.synopsys.integration.blackduck.imageinspector.image.common.RepoTag)2 InspectImageCmd (com.github.dockerjava.api.command.InspectImageCmd)1 InspectImageResponse (com.github.dockerjava.api.command.InspectImageResponse)1 ImageTarWrapper (com.synopsys.integration.blackduck.dockerinspector.output.ImageTarWrapper)1 BlackDuckIntegrationException (com.synopsys.integration.blackduck.exception.BlackDuckIntegrationException)1 ImageNameResolver (com.synopsys.integration.blackduck.imageinspector.api.name.ImageNameResolver)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 File (java.io.File)1