use of com.epam.pipeline.entity.configuration.ConfigurationEntry in project cloud-pipeline by epam.
the class PipelineConfigurationManager method getConfigurationForToolRunOrPipelineRun.
private PipelineConfiguration getConfigurationForToolRunOrPipelineRun(final PipelineStart runVO, final Tool tool, final boolean toolRun) {
PipelineConfiguration defaultConfiguration;
ConfigurationEntry entry;
if (toolRun) {
entry = getConfigurationForToolVersion(tool.getId(), runVO.getDockerImage(), runVO.getConfigurationName());
} else {
entry = initRegisteredPipelineConfiguration(runVO.getPipelineId(), runVO.getVersion(), runVO.getConfigurationName());
}
defaultConfiguration = entry == null ? new PipelineConfiguration() : entry.getConfiguration();
if (!StringUtils.hasText(runVO.getConfigurationName()) && entry != null) {
runVO.setConfigurationName(entry.getName());
}
return defaultConfiguration;
}
use of com.epam.pipeline.entity.configuration.ConfigurationEntry in project cloud-pipeline by epam.
the class PipelineVersionManager method addConfiguration.
public List<ConfigurationEntry> addConfiguration(Long id, ConfigurationEntry configuration) throws GitClientException {
Assert.isTrue(configuration.checkConfigComplete(), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_INVALID));
String configurationName = configuration.getName();
Pipeline pipeline = pipelineManager.load(id, true);
List<ConfigurationEntry> currentConfigurations = getCurrentConfigurations(pipeline);
checkDefaultConfig(configuration, currentConfigurations);
List<ConfigurationEntry> updatedConf = removeConfig(configurationName, currentConfigurations);
updatedConf.add(configuration);
String message = messageHelper.getMessage(MessageConstants.INFO_CONFIG_UPDATE, configurationName);
return saveUpdatedConfiguration(configurationName, pipeline, updatedConf, message);
}
use of com.epam.pipeline.entity.configuration.ConfigurationEntry in project cloud-pipeline by epam.
the class PipelineVersionManager method renameConfiguration.
public List<ConfigurationEntry> renameConfiguration(Long id, String oldName, String newName) throws GitClientException {
Assert.isTrue(StringUtils.hasText(oldName), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_REQUIRED));
Assert.isTrue(StringUtils.hasText(newName), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_REQUIRED));
Pipeline pipeline = pipelineManager.load(id, true);
List<ConfigurationEntry> currentConfigurations = getCurrentConfigurations(pipeline);
ConfigurationEntry oldConfig = findConfigByName(currentConfigurations, oldName);
Assert.notNull(oldConfig, messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NOT_FOUND, oldName));
Assert.isTrue(findConfigByName(currentConfigurations, newName) == null, messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_EXISTS, newName));
currentConfigurations.forEach(config -> {
if (oldName.equals(config.getName())) {
config.setName(newName);
}
});
String message = messageHelper.getMessage(MessageConstants.INFO_CONFIG_RENAME, oldName, newName);
return saveUpdatedConfiguration(newName, pipeline, currentConfigurations, message);
}
use of com.epam.pipeline.entity.configuration.ConfigurationEntry in project cloud-pipeline by epam.
the class PipelineVersionManager method deleteConfiguration.
public List<ConfigurationEntry> deleteConfiguration(Long id, String configName) throws GitClientException {
Assert.notNull(configName, messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NAME_REQUIRED));
Pipeline pipeline = pipelineManager.load(id, true);
List<ConfigurationEntry> currentConfigurations = getCurrentConfigurations(pipeline);
List<ConfigurationEntry> updatedConf = removeConfig(configName, currentConfigurations);
Assert.isTrue(currentConfigurations.size() != updatedConf.size(), messageHelper.getMessage(MessageConstants.ERROR_CONFIG_NOT_FOUND, configName));
String message = messageHelper.getMessage(MessageConstants.INFO_CONFIG_DELETE, configName);
return saveUpdatedConfiguration(configName, pipeline, updatedConf, message);
}
use of com.epam.pipeline.entity.configuration.ConfigurationEntry in project cloud-pipeline by epam.
the class ToolVersionDaoTest method shouldCRUDWithSettings.
@Test
public void shouldCRUDWithSettings() {
Long toolId = tool.getId();
PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
pipelineConfiguration.setCmdTemplate(TEST_CMD_TEMPLATE_1);
pipelineConfiguration.setNodeCount(TEST_NODE_COUNT);
pipelineConfiguration.setParameters(Collections.singletonMap(TEST_PARAMETER_NAME, new PipeConfValueVO(TEST_PARAMETER_VALUE)));
ConfigurationEntry configurationEntry = new ConfigurationEntry(pipelineConfiguration);
List<ConfigurationEntry> settings = Collections.singletonList(configurationEntry);
toolVersion1.setSettings(settings);
toolVersionDao.createToolVersionWithSettings(toolVersion1);
ToolVersion actual = toolVersionDao.loadToolVersionWithSettings(toolId, TEST_VERSION).orElse(null);
validateToolVersionSettings(actual, configurationEntry, TEST_VERSION, toolId, TEST_PARAMETER_NAME);
pipelineConfiguration.setCmdTemplate(TEST_CMD_TEMPLATE_2);
configurationEntry.setConfiguration(pipelineConfiguration);
settings = Collections.singletonList(configurationEntry);
toolVersion1.setSettings(settings);
toolVersionDao.updateToolVersionWithSettings(toolVersion1);
actual = toolVersionDao.loadToolVersionWithSettings(toolId, TEST_VERSION).orElse(null);
validateToolVersionSettings(actual, configurationEntry, TEST_VERSION, toolId, TEST_PARAMETER_NAME);
toolVersionDao.deleteToolVersions(toolId);
actual = toolVersionDao.loadToolVersion(toolId, TEST_VERSION).orElse(null);
assertThat(actual).isNull();
}
Aggregations