Search in sources :

Example 1 with OutputFiles

use of com.synopsys.integration.blackduck.dockerinspector.output.OutputFiles in project blackduck-docker-inspector by blackducksoftware.

the class HttpClientInspector method getBdio.

public Result getBdio() throws IntegrationException, InterruptedException {
    ImageInspectorClient imageInspectorClient = chooseImageInspectorClient();
    try {
        output.ensureWorkingOutputDirIsWriteable();
        ImageTarWrapper finalDockerTarfile = prepareDockerTarfile(imageInspectorClient);
        String containerFileSystemFilename = containerFilesystemFilename.deriveContainerFilesystemFilename(finalDockerTarfile.getImageRepo(), finalDockerTarfile.getImageTag());
        String dockerTarFilePathInContainer = containerPaths.getContainerPathToTargetFile(finalDockerTarfile.getFile().getCanonicalPath());
        String containerFileSystemPathInContainer = null;
        if (config.isOutputIncludeContainerfilesystem() || config.isOutputIncludeSquashedImage()) {
            containerFileSystemPathInContainer = containerPaths.getContainerPathToOutputFile(containerFileSystemFilename);
        }
        String bdioString = imageInspectorClient.getBdio(finalDockerTarfile.getFile().getCanonicalPath(), dockerTarFilePathInContainer, config.getDockerImageRepo(), config.getDockerImageTag(), containerFileSystemPathInContainer, config.getContainerFileSystemExcludedPaths(), config.isOrganizeComponentsByLayer(), config.isIncludeRemovedComponents(), config.isCleanupWorkingDir(), config.getDockerPlatformTopLayerId(), config.getTargetImageLinuxDistroOverride());
        logger.trace(String.format("bdioString: %s", bdioString));
        SimpleBdioDocument bdioDocument = toBdioDocument(bdioString);
        adjustBdio(bdioDocument);
        OutputFiles outputFiles = output.addOutputToFinalOutputDir(bdioDocument, finalDockerTarfile.getImageRepo(), finalDockerTarfile.getImageTag());
        if (config.isUploadBdio()) {
            NameVersion projectAndVersion = new NameVersion(bdioDocument.getProject().name, bdioDocument.getProject().version);
            blackDuckClient.uploadBdio(outputFiles.getBdioFile(), bdioDocument.getBillOfMaterials().spdxName, projectAndVersion);
        }
        cleanup();
        Result result = Result.createResultSuccess(finalDockerTarfile.getImageRepo(), finalDockerTarfile.getImageTag(), finalDockerTarfile.getFile().getName(), outputFiles.getBdioFile(), outputFiles.getContainerFileSystemFile(), outputFiles.getSquashedImageFile());
        return result;
    } catch (IOException e) {
        throw new IntegrationException(e.getMessage(), e);
    }
}
Also used : ImageTarWrapper(com.synopsys.integration.blackduck.dockerinspector.output.ImageTarWrapper) NameVersion(com.synopsys.integration.util.NameVersion) IntegrationException(com.synopsys.integration.exception.IntegrationException) OutputFiles(com.synopsys.integration.blackduck.dockerinspector.output.OutputFiles) IOException(java.io.IOException) SimpleBdioDocument(com.synopsys.integration.bdio.model.SimpleBdioDocument) Result(com.synopsys.integration.blackduck.dockerinspector.output.Result)

Aggregations

SimpleBdioDocument (com.synopsys.integration.bdio.model.SimpleBdioDocument)1 ImageTarWrapper (com.synopsys.integration.blackduck.dockerinspector.output.ImageTarWrapper)1 OutputFiles (com.synopsys.integration.blackduck.dockerinspector.output.OutputFiles)1 Result (com.synopsys.integration.blackduck.dockerinspector.output.Result)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 NameVersion (com.synopsys.integration.util.NameVersion)1 IOException (java.io.IOException)1