use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.
the class ToolManager method deleteToolIcon.
@Transactional(propagation = Propagation.REQUIRED)
public void deleteToolIcon(long toolId) {
Tool tool = load(toolId);
Assert.notNull(tool, messageHelper.getMessage(MessageConstants.ERROR_TOOL_NOT_FOUND, toolId));
toolDao.deleteToolIcon(toolId);
}
use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.
the class ToolManager method updateTool.
@Transactional(propagation = Propagation.REQUIRED)
public Tool updateTool(Tool tool) {
Tool loadedTool = toolDao.loadTool(tool.getRegistryId(), tool.getImage());
Assert.notNull(loadedTool, messageHelper.getMessage(MessageConstants.ERROR_TOOL_NOT_FOUND, tool.getImage()));
if (!StringUtils.isEmpty(tool.getCpu())) {
loadedTool.setCpu(tool.getCpu());
}
if (!StringUtils.isEmpty(tool.getRam())) {
loadedTool.setRam(tool.getRam());
}
validateInstanceType(tool);
loadedTool.setInstanceType(tool.getInstanceType());
loadedTool.setDisk(tool.getDisk());
loadedTool.setDescription(tool.getDescription());
loadedTool.setShortDescription(tool.getShortDescription());
loadedTool.setLabels(tool.getLabels());
loadedTool.setEndpoints(tool.getEndpoints());
loadedTool.setDefaultCommand(tool.getDefaultCommand());
toolDao.updateTool(loadedTool);
return loadedTool;
}
use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.
the class ToolManager method loadToolAttributes.
public ToolDescription loadToolAttributes(Long toolId) {
Tool tool = load(toolId);
Map<String, ToolVersionScanResult> versionScanResults = toolVulnerabilityDao.loadAllToolVersionScans(toolId);
ToolDescription toolDescription = new ToolDescription();
toolDescription.setToolId(toolId);
List<ToolVersionAttributes> versions = ListUtils.emptyIfNull(loadTags(toolId)).stream().map(version -> ToolVersionAttributes.builder().version(version).attributes(getToolVersion(toolId, version)).scanResult(getToolVersionScanResult(tool, versionScanResults, version)).build()).collect(Collectors.toList());
toolDescription.setVersions(versions);
return toolDescription;
}
use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.
the class ToolManager method getCurrentImageSize.
public long getCurrentImageSize(final String dockerImage) {
LOGGER.info("Getting size of image {}", dockerImage);
Tool tool = loadByNameOrId(dockerImage);
DockerRegistry dockerRegistry = dockerRegistryManager.load(tool.getRegistryId());
String imageWithoutTag = getImageWithoutTag(tool.getImage());
String tag = getTagFromImageName(dockerImage);
DockerClient dockerClient = dockerRegistryManager.getDockerClient(dockerRegistry, imageWithoutTag);
try {
ToolVersion toolVersion = dockerClient.getVersionAttributes(dockerRegistry, imageWithoutTag, tag);
if (Objects.isNull(toolVersion) || Objects.isNull(toolVersion.getSize())) {
LOGGER.warn(messageHelper.getMessage(MessageConstants.ERROR_TOOL_VERSION_INVALID_SIZE, dockerImage));
return 0;
}
return toolVersion.getSize();
} catch (IllegalArgumentException e) {
LOGGER.error("An error occurred while getting image size: {} ", e.getMessage());
return 0;
}
}
use of com.epam.pipeline.entity.pipeline.Tool in project cloud-pipeline by epam.
the class ToolManager method fetchTool.
private Tool fetchTool(String registry, String image) {
Long registryId = !StringUtils.isEmpty(registry) ? dockerRegistryManager.loadByNameOrId(registry).getId() : null;
Tool tool = toolDao.loadTool(registryId, getImageWithoutTag(image));
Assert.notNull(tool, messageHelper.getMessage(MessageConstants.ERROR_TOOL_NOT_FOUND, image));
return tool;
}
Aggregations