use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class BasicCruiseConfig method getUniqueMaterials.
private Set<MaterialConfig> getUniqueMaterials(boolean ignoreManualPipelines, boolean ignoreConfigRepos) {
Set<MaterialConfig> materialConfigs = new HashSet<>();
Set<Map> uniqueMaterials = new HashSet<>();
for (PipelineConfig pipelineConfig : pipelinesFromAllGroups()) {
for (MaterialConfig materialConfig : pipelineConfig.materialConfigs()) {
if (!uniqueMaterials.contains(materialConfig.getSqlCriteria())) {
boolean shouldSkipPolling = !materialConfig.isAutoUpdate();
boolean scmOrPackageMaterial = !(materialConfig instanceof DependencyMaterialConfig);
if (ignoreManualPipelines && scmOrPackageMaterial && shouldSkipPolling) {
continue;
}
materialConfigs.add(materialConfig);
uniqueMaterials.add(materialConfig.getSqlCriteria());
}
}
}
if (!ignoreConfigRepos) {
for (ConfigRepoConfig configRepo : this.configRepos) {
MaterialConfig materialConfig = configRepo.getMaterialConfig();
if (!uniqueMaterials.contains(materialConfig.getSqlCriteria())) {
materialConfigs.add(materialConfig);
uniqueMaterials.add(materialConfig.getSqlCriteria());
}
}
}
return materialConfigs;
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class BasicCruiseConfig method generatePipelineVsDownstreamMap.
@Override
public Map<String, List<PipelineConfig>> generatePipelineVsDownstreamMap() {
List<PipelineConfig> pipelineConfigs = getAllPipelineConfigs();
Map<String, List<PipelineConfig>> result = new HashMap<>();
for (PipelineConfig currentPipeline : pipelineConfigs) {
String currentPipelineName = currentPipeline.name().toString();
if (!result.containsKey(currentPipelineName)) {
result.put(currentPipelineName, new ArrayList<>());
}
for (MaterialConfig materialConfig : currentPipeline.materialConfigs()) {
if (materialConfig instanceof DependencyMaterialConfig) {
String pipelineWhichTriggersMe = ((DependencyMaterialConfig) materialConfig).getPipelineName().toString();
if (!result.containsKey(pipelineWhichTriggersMe)) {
result.put(pipelineWhichTriggersMe, new ArrayList<>());
}
result.get(pipelineWhichTriggersMe).add(currentPipeline);
}
}
}
return result;
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineConfig method validStagesForFetchArtifact.
public List<StageConfig> validStagesForFetchArtifact(PipelineConfig downstreamPipeline, CaseInsensitiveString currentDownstreamStage) {
for (DependencyMaterialConfig dependencyMaterial : downstreamPipeline.dependencyMaterialConfigs()) {
if (dependencyMaterial.getPipelineName().equals(name)) {
List<StageConfig> stageConfigs = allStagesBefore(dependencyMaterial.getStageName());
// add this stage itself
stageConfigs.add(getStage(dependencyMaterial.getStageName()));
return stageConfigs;
}
}
if (this.equals(downstreamPipeline)) {
return allStagesBefore(currentDownstreamStage);
}
return null;
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class PipelineConfigTreeValidator method validateDependencyMaterialsForDownstreams.
private void validateDependencyMaterialsForDownstreams(PipelineConfigSaveValidationContext validationContext, CaseInsensitiveString selected, PipelineConfig downstreamPipeline) {
Node dependenciesOfSelectedPipeline = validationContext.getDependencyMaterialsFor(selected);
for (Node.DependencyNode dependencyNode : dependenciesOfSelectedPipeline.getDependencies()) {
if (dependencyNode.getPipelineName().equals(pipelineConfig.name())) {
for (MaterialConfig materialConfig : downstreamPipeline.materialConfigs()) {
if (materialConfig instanceof DependencyMaterialConfig) {
DependencyMaterialConfig dependencyMaterialConfig = new Cloner().deepClone((DependencyMaterialConfig) materialConfig);
dependencyMaterialConfig.validate(validationContext.withParent(downstreamPipeline));
List<String> allErrors = dependencyMaterialConfig.errors().getAll();
for (String error : allErrors) {
pipelineConfig.errors().add("base", error);
}
}
}
}
}
}
use of com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig in project gocd by gocd.
the class MaterialConfigs method validateOrigins.
private void validateOrigins(PipelineConfig currentPipeline, ValidationContext validationContext) {
for (DependencyMaterialConfig material : filterDependencyMaterials()) {
PipelineConfig upstream = validationContext.getPipelineConfigByName(material.getPipelineName());
if (upstream == null)
// other rule validates existence of upstream
continue;
ConfigOrigin myOrigin = currentPipeline.getOrigin();
ConfigOrigin upstreamOrigin = upstream.getOrigin();
if (validationContext.shouldCheckConfigRepo()) {
if (!validationContext.getConfigRepos().isReferenceAllowed(myOrigin, upstreamOrigin)) {
material.addError(DependencyMaterialConfig.ORIGIN, String.format("Dependency from pipeline defined in %s to pipeline defined in %s is not allowed", displayNameFor(myOrigin), displayNameFor(upstreamOrigin)));
}
}
}
}
Aggregations