Search in sources :

Example 11 with Tool

use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.

the class ToolManager method loadToolDescription.

public ImageDescription loadToolDescription(Long id, String tag) {
    Tool tool = load(id);
    Assert.notNull(tool, messageHelper.getMessage(MessageConstants.ERROR_TOOL_NOT_FOUND, id));
    return dockerRegistryManager.getImageDescription(dockerRegistryManager.load(tool.getRegistryId()), tool.getImage(), tag);
}
Also used : Tool(com.epam.pipeline.entity.pipeline.Tool)

Example 12 with Tool

use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.

the class GraphReader method parseTool.

private void parseTool(TaskNode currentTask, String line) {
    String value = line.substring(TOOL_START.length());
    if (!StringUtils.isEmpty(value)) {
        String[] toolDescription = value.trim().split("\\s+");
        String image = toolDescription[0];
        if (!image.isEmpty()) {
            Tool tool = new Tool(image);
            currentTask.setTool(tool);
            for (int j = 1; j < toolDescription.length; j++) {
                if (toolDescription[j].startsWith(CPU_PREFIX)) {
                    tool.setCpu(toolDescription[j].substring(CPU_PREFIX.length()));
                } else if (toolDescription[j].startsWith(RAM_PREFIX)) {
                    tool.setRam(toolDescription[j].substring(RAM_PREFIX.length()));
                } else if (toolDescription[j].startsWith(REGISTRY_PREFIX)) {
                    tool.setRam(toolDescription[j].substring(REGISTRY_PREFIX.length()));
                }
            }
        }
    }
}
Also used : Tool(com.epam.pipeline.entity.pipeline.Tool)

Example 13 with Tool

use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.

the class ToolDaoTest method sameToolsInDifferentRegistryShouldBeWorksCorrectly.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void sameToolsInDifferentRegistryShouldBeWorksCorrectly() {
    Tool tool = generateTool();
    tool.setRegistryId(firstRegistry.getId());
    tool.setToolGroupId(library1.getId());
    toolDao.createTool(tool);
    tool.setRegistryId(secondRegistry.getId());
    tool.setToolGroupId(library2.getId());
    toolDao.createTool(tool);
    List<Tool> tools = toolDao.loadAllTools();
    Assert.assertEquals(2, tools.size());
    Tool first = toolDao.loadTool(firstRegistry.getId(), tool.getImage());
    checkLoadedTool(first, firstRegistry.getId(), TEST_REPO);
    Tool second = toolDao.loadTool(secondRegistry.getId(), tool.getImage());
    checkLoadedTool(second, secondRegistry.getId(), TEST_REPO_2);
    toolDao.deleteTool(second.getId());
    Assert.assertEquals(1, toolDao.loadAllTools().size());
    toolDao.deleteTool(first.getId());
    Assert.assertTrue(toolDao.loadAllTools().isEmpty());
}
Also used : Tool(com.epam.pipeline.entity.pipeline.Tool) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with Tool

use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.

the class ToolDaoTest method generateTool.

public static Tool generateTool() {
    Tool tool = new Tool();
    tool.setImage(TEST_IMAGE);
    tool.setRam(TEST_RAM);
    tool.setCpu(TEST_CPU);
    tool.setOwner(TEST_USER);
    return tool;
}
Also used : Tool(com.epam.pipeline.entity.pipeline.Tool)

Example 15 with Tool

use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.

the class DockerRegistryDaoTest method initTestHierarchy.

private List<DockerRegistry> initTestHierarchy() {
    DockerRegistry createdRegistry = new DockerRegistry();
    createdRegistry.setPath(REGISTRY_PATH);
    createdRegistry.setOwner(TEST_USER);
    registryDao.createDockerRegistry(createdRegistry);
    DockerRegistry createdRegistry2 = new DockerRegistry();
    createdRegistry2.setPath(ANOTHER_REGISTRY_PATH);
    createdRegistry2.setOwner(TEST_USER);
    registryDao.createDockerRegistry(createdRegistry2);
    ToolGroup library = createToolGroup(createdRegistry);
    ToolGroup library2 = createToolGroup(createdRegistry2);
    toolGroupDao.createToolGroup(library);
    toolGroupDao.createToolGroup(library2);
    createdRegistry.setGroups(Collections.singletonList(library));
    createdRegistry2.setGroups(Collections.singletonList(library2));
    Tool tool = createTool(TOOL_IMAGE, createdRegistry.getId(), library);
    toolDao.createTool(tool);
    library.setTools(Collections.singletonList(tool));
    createdRegistry.setTools(Collections.singletonList(tool));
    Tool tool2 = createTool(ANOTHER_TOOL_IMAGE, createdRegistry2.getId(), library2);
    toolDao.createTool(tool2);
    library2.setTools(Collections.singletonList(tool2));
    return Arrays.asList(createdRegistry, createdRegistry2);
}
Also used : DockerRegistry(com.epam.pipeline.entity.pipeline.DockerRegistry) ToolGroup(com.epam.pipeline.entity.pipeline.ToolGroup) Tool(com.epam.pipeline.entity.pipeline.Tool)

Aggregations

Tool (com.epam.pipeline.entity.pipeline.Tool)72 Transactional (org.springframework.transaction.annotation.Transactional)28 DockerRegistry (com.epam.pipeline.entity.pipeline.DockerRegistry)24 Test (org.junit.Test)22 ToolGroup (com.epam.pipeline.entity.pipeline.ToolGroup)14 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)11 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)9 DockerClient (com.epam.pipeline.manager.docker.DockerClient)9 List (java.util.List)9 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)8 MessageHelper (com.epam.pipeline.common.MessageHelper)7 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)7 ToolVersionScanResult (com.epam.pipeline.entity.scan.ToolVersionScanResult)7 ToolScanExternalServiceException (com.epam.pipeline.exception.ToolScanExternalServiceException)7 DockerRegistryManager (com.epam.pipeline.manager.docker.DockerRegistryManager)7 Optional (java.util.Optional)7 MessageConstants (com.epam.pipeline.common.MessageConstants)6 ManifestV2 (com.epam.pipeline.entity.docker.ManifestV2)6 ToolScanStatus (com.epam.pipeline.entity.pipeline.ToolScanStatus)6 DockerClientFactory (com.epam.pipeline.manager.docker.DockerClientFactory)6