use of com.epam.pipeline.entity.configuration.PipelineConfiguration 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();
}
use of com.epam.pipeline.entity.configuration.PipelineConfiguration in project cloud-pipeline by epam.
the class ClusterManagerImpl method configurationToInstance.
@Override
public RunInstance configurationToInstance(PipelineConfiguration configuration) {
RunInstance instance = new RunInstance();
if (configuration.getInstanceType() == null) {
instance.setNodeType(preferenceManager.getPreference(SystemPreferences.CLUSTER_INSTANCE_TYPE));
} else {
instance.setNodeType(configuration.getInstanceType());
}
if (configuration.getInstanceDisk() == null) {
instance.setNodeDisk(preferenceManager.getPreference(SystemPreferences.CLUSTER_INSTANCE_HDD));
} else {
instance.setNodeDisk(Integer.parseInt(configuration.getInstanceDisk()));
}
instance.setEffectiveNodeDisk(instance.getNodeDisk());
if (configuration.getInstanceImage() == null) {
instance.setNodeImage(preferenceManager.getPreference(SystemPreferences.CLUSTER_INSTANCE_IMAGE));
} else {
instance.setNodeImage(configuration.getInstanceImage());
}
instance.setAwsRegionId(Optional.ofNullable(configuration.getAwsRegionId()).map(regionId -> awsRegionManager.load(regionId)).orElse(awsRegionManager.loadDefaultRegion()).getAwsRegionName());
return instance;
}
use of com.epam.pipeline.entity.configuration.PipelineConfiguration in project cloud-pipeline by epam.
the class ToolSecurityPolicyAspect method checkToolBySecurityPolicy.
@Before("@annotation(com.epam.pipeline.manager.docker.scan.ToolSecurityPolicyCheck) && args(runVO,..)")
public void checkToolBySecurityPolicy(JoinPoint joinPoint, PipelineStart runVO) {
if (runVO.isForce()) {
PipelineUser user = authManager.getCurrentUser();
if (user != null && user.isAdmin()) {
return;
}
}
PipelineConfiguration configuration = configurationManager.getPipelineConfiguration(runVO);
String tag = toolManager.getTagFromImageName(configuration.getDockerImage());
Tool tool = toolManager.loadByNameOrId(configuration.getDockerImage());
if (!clairToolScanManager.checkTool(tool, tag)) {
throw new ToolExecutionDeniedException(messageHelper.getMessage(MessageConstants.ERROR_TOOL_SECURITY_POLICY_VIOLATION));
}
}
use of com.epam.pipeline.entity.configuration.PipelineConfiguration in project cloud-pipeline by epam.
the class EnvVarsBuilder method buildEnvVars.
public static List<EnvVar> buildEnvVars(PipelineRun run, PipelineConfiguration configuration, Map<SystemParams, String> sysParams, Map<String, String> externalProperties) {
List<EnvVar> fullEnvVars = new ArrayList<>();
Map<String, String> envVarsMap = new HashMap<>();
sysParams.entrySet().stream().map(sysParam -> {
String name = sysParam.getKey().getEnvName();
String value = sysParam.getValue();
if (!sysParam.getKey().isSecure()) {
envVarsMap.put(name, value);
}
return new EnvVar(name, value, null);
}).forEach(fullEnvVars::add);
configuration.getParameters().entrySet().stream().map(parameter -> {
String name = parameter.getKey();
String value = parameter.getValue().getValue();
String type = parameter.getValue().getType();
return matchParameterToEnvVars(name, value, type, envVarsMap);
}).flatMap(Arrays::stream).forEach(fullEnvVars::add);
configuration.getEnvironmentParams().entrySet().stream().map(parameter -> {
String name = parameter.getKey();
String value = parameter.getValue();
envVarsMap.put(name, value);
return new EnvVar(name, value, null);
}).forEach(fullEnvVars::add);
if (!MapUtils.isEmpty(externalProperties)) {
externalProperties.entrySet().stream().map(property -> {
String name = getBashName(property.getKey());
envVarsMap.put(name, property.getValue());
return new EnvVar(name, property.getValue(), null);
}).forEach(fullEnvVars::add);
}
run.setEnvVars(envVarsMap);
return fullEnvVars;
}
use of com.epam.pipeline.entity.configuration.PipelineConfiguration in project cloud-pipeline by epam.
the class PipelineConfigurationForRunnerTest method shouldGetSpecifiedConfigurationForToolVersionRun.
@Test
public void shouldGetSpecifiedConfigurationForToolVersionRun() {
Tool tool = new Tool();
tool.setImage(TEST_IMAGE);
tool.setRam(TEST_RAM);
tool.setCpu(TEST_CPU);
ConfigurationEntry otherConfigurationEntry = new ConfigurationEntry();
otherConfigurationEntry.setName(TEST_CONFIGURATION_NAME);
PipelineConfiguration pipelineConfiguration = new PipelineConfiguration();
pipelineConfiguration.setInstanceDisk(TEST_HDD_SIZE);
otherConfigurationEntry.setConfiguration(pipelineConfiguration);
when(toolVersionManagerMock.loadToolVersionSettings(anyLong(), anyString())).thenReturn(Collections.singletonList(ToolVersion.builder().settings(Arrays.asList(configurationEntry, otherConfigurationEntry)).build()));
PipelineStart vo = getPipelineStartVO();
vo.setHddSize(null);
vo.setConfigurationName(TEST_CONFIGURATION_NAME);
PipelineConfiguration config = pipelineConfigurationManager.getPipelineConfiguration(vo, tool);
commonPipelineConfigurationAssertions(config);
assertThat(config).hasFieldOrPropertyWithValue(INSTANCE_DISK_FIELD, // from configuration
TEST_HDD_SIZE);
assertThat(config.getParameters()).isNotEmpty().hasSize(1).containsKeys(TEST_PARAM_1);
}
Aggregations