use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class MergeCruiseConfigTest method shouldGetUniqueMaterialsWithConfigRepos.
@Test
public void shouldGetUniqueMaterialsWithConfigRepos() {
BasicCruiseConfig mainCruiseConfig = new BasicCruiseConfig(pipelines);
ConfigReposConfig reposConfig = new ConfigReposConfig();
GitMaterialConfig configRepo = new GitMaterialConfig("http://git");
reposConfig.add(new ConfigRepoConfig(configRepo, "myplug"));
mainCruiseConfig.setConfigRepos(reposConfig);
PartialConfig partialConfig = PartialConfigMother.withPipeline("pipe2");
MaterialConfig pipeRepo = partialConfig.getGroups().get(0).get(0).materialConfigs().get(0);
cruiseConfig = new BasicCruiseConfig(mainCruiseConfig, partialConfig);
Set<MaterialConfig> materials = cruiseConfig.getAllUniqueMaterialsBelongingToAutoPipelinesAndConfigRepos();
assertThat(materials, hasItem(configRepo));
assertThat(materials, hasItem(pipeRepo));
assertThat(materials.size(), is(2));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class MergeCruiseConfigTest method shouldGetUniqueMaterialsWithoutConfigRepos.
@Test
public void shouldGetUniqueMaterialsWithoutConfigRepos() {
BasicCruiseConfig mainCruiseConfig = new BasicCruiseConfig(pipelines);
ConfigReposConfig reposConfig = new ConfigReposConfig();
GitMaterialConfig configRepo = new GitMaterialConfig("http://git");
reposConfig.add(new ConfigRepoConfig(configRepo, "myplug"));
mainCruiseConfig.setConfigRepos(reposConfig);
PartialConfig partialConfig = PartialConfigMother.withPipeline("pipe2");
MaterialConfig pipeRepo = partialConfig.getGroups().get(0).get(0).materialConfigs().get(0);
cruiseConfig = new BasicCruiseConfig(mainCruiseConfig, partialConfig);
Set<MaterialConfig> materials = cruiseConfig.getAllUniqueMaterialsBelongingToAutoPipelines();
assertThat(materials, hasItem(pipeRepo));
assertThat(materials.size(), is(1));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class PipelineGroups method getAllUniquePostCommitSchedulableMaterials.
public Set<MaterialConfig> getAllUniquePostCommitSchedulableMaterials() {
Set<MaterialConfig> materialConfigs = new HashSet<>();
Set<String> uniqueMaterials = new HashSet<>();
for (PipelineConfigs pipelineConfigs : this) {
for (PipelineConfig pipelineConfig : pipelineConfigs) {
for (MaterialConfig materialConfig : pipelineConfig.materialConfigs()) {
if ((materialConfig instanceof ScmMaterialConfig || materialConfig instanceof PluggableSCMMaterialConfig) && !materialConfig.isAutoUpdate() && !uniqueMaterials.contains(materialConfig.getFingerprint())) {
materialConfigs.add(materialConfig);
uniqueMaterials.add(materialConfig.getFingerprint());
}
}
}
}
return materialConfigs;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ScheduledPipelineLoader method knownMaterials.
private MaterialConfigs knownMaterials(Pipeline pipeline, MaterialRevisions scheduledRevs) {
CruiseConfig currentConfig = goConfigService.getCurrentConfig();
MaterialConfigs configuredMaterials = new MaterialConfigs();
for (MaterialRevision revision : scheduledRevs) {
String fingerprint = revision.getMaterial().getFingerprint();
// first try to find material config from current pipeline config
MaterialConfig configuredMaterial = currentConfig.materialConfigFor(new CaseInsensitiveString(pipeline.getName()), fingerprint);
if (configuredMaterial != null) {
configuredMaterials.add(configuredMaterial);
continue;
}
// todo: remove the global lookup fallback code after we feel safe
if (new SystemEnvironment().get(SystemEnvironment.GO_SERVER_SCHEDULED_PIPELINE_LOADER_GLOBAL_MATERIAL_LOOKUP)) {
// fallback to global lookup if material is not in current pipeline config (old behavior)
configuredMaterial = currentConfig.materialConfigFor(fingerprint);
if (configuredMaterial != null) {
configuredMaterials.add((configuredMaterial));
}
}
}
MaterialConfigs knownMaterials = new MaterialConfigs();
for (MaterialConfig configuredMaterial : configuredMaterials) {
materialExpansionService.expandForScheduling(configuredMaterial, knownMaterials);
}
return knownMaterials;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class DependencyFanInNode method validateIfRevisionMatchesTheCurrentConfigAndUpdateTheMaterialMap.
private void validateIfRevisionMatchesTheCurrentConfigAndUpdateTheMaterialMap(FanInGraphContext context, Pair<StageIdentifier, List<FaninScmMaterial>> stageIdentifierScmPair) {
final Set<MaterialConfig> currentScmMaterials = context.pipelineScmDepMap.get(materialConfig);
final Set<FaninScmMaterial> scmMaterials = new HashSet<>(stageIdentifierScmPair.last());
final Set<String> currentScmFingerprint = new HashSet<>();
for (MaterialConfig currentScmMaterial : currentScmMaterials) {
currentScmFingerprint.add(currentScmMaterial.getFingerprint());
}
final Set<String> scmMaterialsFingerprint = new HashSet<>();
for (FaninScmMaterial scmMaterial : scmMaterials) {
scmMaterialsFingerprint.add(scmMaterial.fingerprint);
}
final Collection commonMaterials = CollectionUtils.intersection(currentScmFingerprint, scmMaterialsFingerprint);
if (commonMaterials.size() == scmMaterials.size() && commonMaterials.size() == currentScmMaterials.size()) {
stageIdentifierScmMaterial.put(stageIdentifierScmPair.first(), scmMaterials);
++currentCount;
} else {
Collection disjunctionWithConfig = CollectionUtils.disjunction(currentScmFingerprint, commonMaterials);
Collection disjunctionWithInstance = CollectionUtils.disjunction(scmMaterialsFingerprint, commonMaterials);
LOGGER.warn("[Fan-in] - Incompatible materials for {}. Config: {}. Instance: {}.", stageIdentifierScmPair.first().getStageLocator(), disjunctionWithConfig, disjunctionWithInstance);
// This is it. We will not go beyond this revision in history
totalInstanceCount = currentCount;
}
}
Aggregations