use of com.synopsys.integration.blackduck.imageinspector.api.name.ImageNameResolver in project blackduck-docker-inspector by blackducksoftware.
the class DockerClientManagerTest method setUp.
@BeforeAll
public static void setUp() {
Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.setLevel(Level.INFO);
Logger integrationLogger = (Logger) LoggerFactory.getLogger("com.synopsys.integration");
integrationLogger.setLevel(Level.DEBUG);
config = Mockito.mock(Config.class);
programPaths = Mockito.mock(ProgramPaths.class);
FileOperations fileOperations = new FileOperations();
dockerClientManager = new DockerClientManager(fileOperations, new ImageNameResolver(), config, new ImageTarFilename(), programPaths);
}
use of com.synopsys.integration.blackduck.imageinspector.api.name.ImageNameResolver in project blackduck-docker-inspector by blackducksoftware.
the class OutputTest method testSquashedImageCreation.
@Test
public void testSquashedImageCreation() throws IOException, IntegrationException {
Mockito.when(config.getOutputPath()).thenReturn(outputDir.getAbsolutePath());
Mockito.when(config.isOutputIncludeSquashedImage()).thenReturn(true);
Mockito.when(programPaths.getUserOutputDirPath()).thenReturn(outputDir.getAbsolutePath());
Mockito.when(programPaths.getDockerInspectorWorkingOutputPath()).thenReturn(workingDir.getAbsolutePath());
Mockito.when(programPaths.getDockerInspectorSquashedImageTarFilePath()).thenReturn(squashedImageTarfile.getAbsolutePath());
Mockito.when(programPaths.getDockerInspectorSquashedImageDirPath()).thenReturn(squashingTempDir.getAbsolutePath());
SimpleBdioDocument bdioDoc = Mockito.mock(SimpleBdioDocument.class);
BdioBillOfMaterials bom = new BdioBillOfMaterials();
bom.spdxName = "registry.luciddg.com_luciddg_ldg-server-qa_2020.16.03_DPKG";
Mockito.when(bdioDoc.getBillOfMaterials()).thenReturn(bom);
BdioProject project = new BdioProject();
Mockito.when(bdioDoc.getProject()).thenReturn(project);
Mockito.when(containerFilesystemFilename.deriveContainerFilesystemFilename(null, null)).thenReturn("target_containerfilesystem.tar.gz");
ImageTarFilename imageTarFilename = new ImageTarFilename();
FileOperations fileOperations = new FileOperations();
DockerClientManager dockerClientManager = new DockerClientManager(fileOperations, new ImageNameResolver(), config, imageTarFilename, programPaths);
SquashedImage squashedImage = new SquashedImage();
squashedImage.setFileOperations(fileOperations);
squashedImage.setDockerClientManager(dockerClientManager);
output.setSquashedImage(squashedImage);
// Test
OutputFiles outputFiles = output.addOutputToFinalOutputDir(bdioDoc, null, null);
// Verify
File generatedSquashedImageCompressedFile = outputFiles.getSquashedImageFile();
File generatedSquashedImageTarfile = new File(workingDir, "generatedImageTarfile");
CompressedFile.gunZipFile(generatedSquashedImageCompressedFile, generatedSquashedImageTarfile);
File generatedSquashedImageContents = new File(workingDir, "generatedSquashedImageContents");
CompressedFile.unTarFile(generatedSquashedImageTarfile, generatedSquashedImageContents);
System.out.println(String.format("Look in: %s", generatedSquashedImageContents.getAbsolutePath()));
Collection<File> layerFiles = FileUtils.listFiles(generatedSquashedImageContents, new NameFileFilter("layer.tar"), TrueFileFilter.TRUE);
assertEquals(1, layerFiles.size());
File generatedLayer = new File(workingDir, "generatedLayer");
CompressedFile.unTarFile(layerFiles.iterator().next(), generatedLayer);
File expectedFile = new File(generatedLayer, "opt/luciddg-server/modules/django/bin/100_assets.csv");
assertTrue(expectedFile.exists());
}
use of com.synopsys.integration.blackduck.imageinspector.api.name.ImageNameResolver 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.api.name.ImageNameResolver in project blackduck-docker-inspector by blackducksoftware.
the class SquashedImageTest method setUp.
@BeforeAll
static void setUp() throws IOException {
Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.setLevel(Level.INFO);
Logger integrationLogger = (Logger) LoggerFactory.getLogger("com.synopsys.integration");
integrationLogger.setLevel(Level.DEBUG);
testWorkingDir = new File("test/output/squashingTest");
ImageTarFilename imageTarFilename = new ImageTarFilename();
FileOperations fileOperations = new FileOperations();
Config config = Mockito.mock(Config.class);
Mockito.when(config.getWorkingDirPath()).thenReturn(testWorkingDir.getCanonicalPath());
ProgramPaths programPaths = new ProgramPaths(config, new ProcessId());
dockerClientManager = new DockerClientManager(fileOperations, new ImageNameResolver(), config, imageTarFilename, programPaths);
squashedImage = new SquashedImage();
squashedImage.setDockerClientManager(dockerClientManager);
squashedImage.setFileOperations(new FileOperations());
}
Aggregations