use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.
the class ExcludeNonExistingConfigLayerTestCase method createFeaturePacks.
@Override
protected void createFeaturePacks(FeaturePackCreator creator) throws ProvisioningException {
prod1 = newFpl("prod1", "1", "1.0.0.Final");
creator.newFeaturePack().setFPID(prod1.getFPID()).addFeatureSpec(FeatureSpec.builder("specA").addParam(FeatureParameterSpec.createId("id")).addParam(FeatureParameterSpec.create("p1", "spec")).addParam(FeatureParameterSpec.create("p2", "spec")).addParam(FeatureParameterSpec.create("p3", "spec")).build()).addConfigLayer(ConfigLayerSpec.builder().setModel("model1").setName("base").addFeature(new FeatureConfig("specA").setParam("id", "base-prod1").setParam("p2", "base")).addPackageDep("base").build()).addConfigLayer(ConfigLayerSpec.builder().setModel("model1").setName("layer1").addLayerDep("base", true).addFeature(new FeatureConfig("specA").setParam("id", "base-prod2").setParam("p2", "layer1")).build()).newPackage("base").writeContent("base.txt", "base");
}
use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.
the class ProvisioningWithConfigTestCase method testMainAdvanced.
@Test
public void testMainAdvanced() throws Exception {
ProvisioningConfig found = validator.validateAndParse("xml/provisioning/provisioning-config2.xml", null, null);
ProvisioningConfig expected = ProvisioningConfig.builder().addFeaturePackDep("foo", FeaturePackConfig.builder(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final")).setInheritConfigs(false).addPatch(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.0-patch.Final").getFPID()).addPatch(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.1-patch.Final").getFPID()).includeConfigModel("model1").excludeConfigModel("model2").excludeDefaultConfig("model1", "name1").includeDefaultConfig("model2", "name2").addConfig(ConfigModel.builder().setName("main").addFeatureGroup(FeatureGroup.builder("dep1").setInheritFeatures(true).build()).addFeatureGroup(FeatureGroup.builder("dep2").setInheritFeatures(false).build()).addFeatureGroup(FeatureGroup.builder("dep3").setInheritFeatures(false).includeSpec("spec1").includeFeature(FeatureId.fromString("spec2:p1=v1,p2=v2")).includeFeature(FeatureId.fromString("spec3:p1=v1"), new FeatureConfig("spec3").addFeatureDep(FeatureId.fromString("spec4:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec5:p1=v1,p2=v2")).setParam("p1", "v1").setParam("p2", "v2")).excludeSpec("spec6").excludeSpec("spec7").excludeFeature(FeatureId.fromString("spec8:p1=v1")).excludeFeature(FeatureId.fromString("spec8:p1=v2")).build()).addFeatureGroup(FeatureGroup.builder("dep4").setOrigin("source4").build()).addFeature(new FeatureConfig("spec1").setParam("p1", "v1").setParam("p2", "v2")).addFeature(new FeatureConfig("spec1").addFeatureDep(FeatureId.fromString("spec2:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec3:p3=v3")).setParam("p1", "v3").setParam("p2", "v4")).setInheritLayers(false).includeLayer("layer1").excludeLayer("layer2").includeLayer("layer3").excludeLayer("layer4").setProperty("prop1", "value1").setProperty("prop2", "value2").setConfigDep("id1", new ConfigId("model1", "name1")).setConfigDep("id2", new ConfigId("model2", null)).setConfigDep("id3", new ConfigId(null, "name3")).build()).build()).build();
Assert.assertEquals(expected, found);
}
use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.
the class ProvisioningWithConfigTestCase method testMain.
@Test
public void testMain() throws Exception {
ProvisioningConfig found = validator.validateAndParse("xml/provisioning/provisioning-config.xml", null, null);
ProvisioningConfig expected = ProvisioningConfig.builder().addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final")).setInheritConfigs(false).includeConfigModel("model1").excludeConfigModel("model2").excludeDefaultConfig("model1", "name1").includeDefaultConfig("model2", "name2").addConfig(ConfigModel.builder().setName("main").addFeatureGroup(FeatureGroup.builder("dep1").setInheritFeatures(true).build()).addFeatureGroup(FeatureGroup.builder("dep2").setInheritFeatures(false).build()).addFeatureGroup(FeatureGroup.builder("dep3").setInheritFeatures(false).includeSpec("spec1").includeFeature(FeatureId.fromString("spec2:p1=v1,p2=v2")).includeFeature(FeatureId.fromString("spec3:p1=v1"), new FeatureConfig("spec3").addFeatureDep(FeatureId.fromString("spec4:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec5:p1=v1,p2=v2")).setParam("p1", "v1").setParam("p2", "v2")).excludeSpec("spec6").excludeSpec("spec7").excludeFeature(FeatureId.fromString("spec8:p1=v1")).excludeFeature(FeatureId.fromString("spec8:p1=v2")).build()).addFeatureGroup(FeatureGroup.builder("dep4").setOrigin("source4").build()).addFeature(new FeatureConfig("spec1").setParam("p1", "v1").setParam("p2", "v2")).addFeature(new FeatureConfig("spec1").addFeatureDep(FeatureId.fromString("spec2:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec3:p3=v3")).setParam("p1", "v3").setParam("p2", "v4")).build()).build()).build();
Assert.assertEquals(expected, found);
}
use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method processIncludedFeatures.
void processIncludedFeatures(final ResolvedFeatureGroupConfig pushedFgConfig) throws ProvisioningException {
if (pushedFgConfig.includedFeatures.isEmpty()) {
return;
}
for (Map.Entry<ResolvedFeatureId, FeatureConfig> feature : pushedFgConfig.includedFeatures.entrySet()) {
final FeatureConfig includedFc = feature.getValue();
if (includedFc != null && includedFc.hasParams()) {
final ResolvedFeatureId includedId = feature.getKey();
if (pushedFgConfig.configStack.isFilteredOut(includedId.specId, includedId)) {
continue;
}
// make sure the included ID is in fact present on the feature group branch
if (!pushedFgConfig.configStack.includes(includedId)) {
throw new ProvisioningException(Errors.featureNotInScope(includedId, pushedFgConfig.fg.getId() == null ? "'anonymous'" : pushedFgConfig.fg.getId().toString(), currentOrigin == null ? null : currentOrigin.producer.getLocation().getFPID()));
}
resolveFeature(pushedFgConfig.configStack, includedFc);
}
}
}
use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method resolveIncludedIds.
private Map<ResolvedFeatureId, FeatureConfig> resolveIncludedIds(Map<ResolvedFeatureId, FeatureConfig> includedFeatures, Map<FeatureId, FeatureConfig> features) throws ProvisioningException {
for (Map.Entry<FeatureId, FeatureConfig> included : features.entrySet()) {
final FeatureConfig fc = new FeatureConfig(included.getValue());
final ResolvedFeatureSpec resolvedSpec = getFeatureSpec(fc.getSpecId().getName());
if (parentFeature != null) {
includedFeatures = CollectionUtils.put(includedFeatures, resolvedSpec.resolveIdFromForeignKey(parentFeature.id, fc.getParentRef(), fc.getParams()), fc);
} else {
includedFeatures = CollectionUtils.put(includedFeatures, resolvedSpec.resolveFeatureId(fc.getParams()), fc);
}
}
return includedFeatures;
}
Aggregations