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);
}
}
Aggregations