Search in sources :

Example 61 with FeatureConfig

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");
}
Also used : FeatureConfig(org.jboss.galleon.config.FeatureConfig)

Example 62 with FeatureConfig

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);
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FeatureConfig(org.jboss.galleon.config.FeatureConfig) ConfigId(org.jboss.galleon.config.ConfigId) Test(org.junit.Test)

Example 63 with FeatureConfig

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);
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FeatureConfig(org.jboss.galleon.config.FeatureConfig) Test(org.junit.Test)

Example 64 with FeatureConfig

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);
        }
    }
}
Also used : FeatureConfig(org.jboss.galleon.config.FeatureConfig) ProvisioningException(org.jboss.galleon.ProvisioningException) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 65 with FeatureConfig

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;
}
Also used : FeatureId(org.jboss.galleon.spec.FeatureId) FeatureConfig(org.jboss.galleon.config.FeatureConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

FeatureConfig (org.jboss.galleon.config.FeatureConfig)76 StateDiffPlugin (org.jboss.galleon.plugin.StateDiffPlugin)8 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)6 FeaturePackCreator (org.jboss.galleon.creator.FeaturePackCreator)5 Test (org.junit.Test)4 Map (java.util.Map)3 FeatureId (org.jboss.galleon.spec.FeatureId)3 LinkedHashMap (java.util.LinkedHashMap)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)2 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)2 HashMap (java.util.HashMap)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ConfigId (org.jboss.galleon.config.ConfigId)1 FeatureGroup (org.jboss.galleon.config.FeatureGroup)1 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)1 ResolvedSpecId (org.jboss.galleon.runtime.ResolvedSpecId)1 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)1 SpecId (org.jboss.galleon.spec.SpecId)1 BasicStateDiffPlugin (org.jboss.galleon.userchanges.persist.test.BasicStateDiffPlugin)1