use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.
the class ToolGroupManager method createPrivate.
@Transactional(propagation = Propagation.REQUIRED)
public ToolGroup createPrivate(Long registryId) {
ToolGroup privateGroup = new ToolGroup();
String privateGroupName = makePrivateGroupName();
privateGroup.setName(privateGroupName);
privateGroup.setRegistryId(registryId);
privateGroup.setOwner(authManager.getAuthorizedUser());
privateGroup.setPrivateGroup(true);
DockerRegistry registry = dockerRegistryManager.load(registryId);
Assert.notNull(registry, messageHelper.getMessage(MessageConstants.ERROR_REGISTRY_NOT_FOUND, registryId));
Assert.isTrue(!toolGroupDao.loadToolGroup(privateGroup.getName(), privateGroup.getRegistryId()).isPresent(), messageHelper.getMessage(MessageConstants.ERROR_TOOL_GROUP_ALREADY_EXIST, privateGroup.getName(), registry.getName()));
privateGroup.setParent(registry);
toolGroupDao.createToolGroup(privateGroup);
makePrivate(privateGroup);
return privateGroup;
}
use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.
the class ToolGroupManager method loadWithParents.
@Override
public ToolGroup loadWithParents(final Long id) {
Optional<ToolGroup> loadResult = toolGroupDao.loadToolGroup(id);
if (loadResult.isPresent()) {
ToolGroup toolGroup = loadResult.get();
toolGroup.setParent(new DockerRegistry(toolGroup.getRegistryId()));
}
return loadResult.orElse(null);
}
use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.
the class PipelineRunManager method commitRun.
/**
* Commits docker image and push it to a docker registry from specified run
* @param id {@link PipelineRun} id for pipeline run to be committed
* @param registryId {@link DockerRegistry} id where new image will be pushed
* @param deleteFiles if true files from pipeline working directory will be cleaned
* @param stopPipeline if true pipeline will be stopped after commit
* @param checkSize if true method will check if free disk space is enough for commit operation
* @return {@link PipelineRun} to be committed
*/
@Transactional(propagation = Propagation.REQUIRED)
public PipelineRun commitRun(Long id, Long registryId, String newImageName, boolean deleteFiles, boolean stopPipeline, boolean checkSize) {
if (checkSize) {
Assert.state(checkFreeSpaceAvailable(id), messageHelper.getMessage(MessageConstants.ERROR_INSTANCE_DISK_NOT_ENOUGH));
}
PipelineRun pipelineRun = pipelineRunDao.loadPipelineRun(id);
DockerRegistry dockerRegistry = dockerRegistryManager.load(registryId);
Assert.notNull(pipelineRun, messageHelper.getMessage(MessageConstants.ERROR_RUN_PIPELINES_NOT_FOUND, id));
Assert.state(pipelineRun.getStatus() == TaskStatus.RUNNING, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_RUN_FINISHED, id));
Assert.notNull(dockerRegistry, messageHelper.getMessage(MessageConstants.ERROR_REGISTRY_NOT_FOUND, registryId));
String dockerImageFromRun = retrieveImageName(pipelineRun);
String resolvedImageName = StringUtils.isEmpty(newImageName) ? dockerImageFromRun : newImageName;
// check that there is no tool with this name in another registry
toolManager.assertThatToolUniqueAcrossRegistries(resolvedImageName, dockerRegistry.getPath());
return dockerContainerOperationManager.commitContainer(pipelineRun, dockerRegistry, resolvedImageName, deleteFiles, stopPipeline);
}
use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.
the class DockerRegistryManagerTest method testLoadingImageTags.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadingImageTags() {
DockerRegistry registry = generateRegistry();
registryDao.createDockerRegistry(registry);
ToolGroup group = generateToolGroup(registry);
toolGroupDao.createToolGroup(group);
Tool tool = generateTool(group);
toolManager.create(tool, true);
DockerClient mockClient = Mockito.mock(DockerClient.class);
when(dockerClientFactoryMock.getDockerClient(any(DockerRegistry.class), any())).thenReturn(mockClient);
List<String> expected = Arrays.asList("TAG1", "TAG2");
when(mockClient.getImageTags(ANOTHER_PATH, TEST_IMAGE)).thenReturn(expected);
Assert.assertEquals(expected, dockerRegistryManager.loadImageTags(registry, tool));
}
use of com.epam.pipeline.entity.pipeline.DockerRegistry in project cloud-pipeline by epam.
the class DockerRegistryManagerTest method testDelete.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testDelete() {
TestUtils.configureDockerClientMock(Mockito.mock(DockerClient.class), dockerClientFactoryMock);
DockerRegistry registry = generateRegistry();
registryDao.createDockerRegistry(registry);
ToolGroup group = generateToolGroup(registry);
toolGroupDao.createToolGroup(group);
Tool tool = generateTool(group);
toolManager.create(tool, true);
dockerRegistryManager.delete(registry.getId(), true);
}
Aggregations