Search in sources :

Example 1 with ConfigurationEntry

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;
}
Also used : PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry)

Example 2 with ConfigurationEntry

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);
}
Also used : ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 3 with ConfigurationEntry

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);
}
Also used : ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 4 with ConfigurationEntry

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);
}
Also used : ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 5 with ConfigurationEntry

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();
}
Also used : PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) ToolVersion(com.epam.pipeline.entity.docker.ToolVersion) ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest)

Aggregations

ConfigurationEntry (com.epam.pipeline.entity.configuration.ConfigurationEntry)9 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)5 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)3 Test (org.junit.Test)2 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)1 PipeConfValueVO (com.epam.pipeline.entity.configuration.PipeConfValueVO)1 ToolVersion (com.epam.pipeline.entity.docker.ToolVersion)1 RunInstance (com.epam.pipeline.entity.pipeline.RunInstance)1 Tool (com.epam.pipeline.entity.pipeline.Tool)1 PipelineStart (com.epam.pipeline.entity.pipeline.run.PipelineStart)1 ConfigurationReadingException (com.epam.pipeline.exception.ConfigurationReadingException)1 GitClientException (com.epam.pipeline.exception.git.GitClientException)1 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)1 Before (org.junit.Before)1