Search in sources :

Example 36 with ProvisioningConfig

use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.

the class IncludeDefaultTestCase method testMain.

@Test
public void testMain() throws Exception {
    ProvisioningConfig found = validator.validateAndParse("xml/provisioning/packages-inherit.xml", null, null);
    ProvisioningConfig expected = ProvisioningConfig.builder().addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp1@maven(universe):0#0.0.1")).setInheritPackages(true).build()).addFeaturePackDep(FeaturePackConfig.forLocation(FeaturePackLocation.fromString("fp2@maven(universe):0#0.0.2"))).addFeaturePackDep(FeaturePackConfig.forLocation(FeaturePackLocation.fromString("fp3@maven(universe):0#0.0.3"))).addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp4@maven(universe):0#0.0.3"), false).build()).build();
    Assert.assertEquals(expected, found);
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) Test(org.junit.Test)

Example 37 with ProvisioningConfig

use of org.jboss.galleon.config.ProvisioningConfig 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 38 with ProvisioningConfig

use of org.jboss.galleon.config.ProvisioningConfig 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 39 with ProvisioningConfig

use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.

the class ProvisioningXmlExcludesIncludesTestCase method readIncludeExcludePackages.

@Test
public void readIncludeExcludePackages() throws Exception {
    ProvisioningConfig found = validator.validateAndParse("xml/provisioning/include-exclude-packages.xml");
    ProvisioningConfig expected = ProvisioningConfig.builder().addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp1@maven(universe):0#0.0.1")).setInheritPackages(false).includePackage("p1").build()).addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp2@maven(universe):0#0.0.2")).excludePackage("p2").includePackage("p3").build()).addFeaturePackDep(FeaturePackConfig.builder(FeaturePackLocation.fromString("fp3@maven(universe):0#0.0.3")).setInheritPackages(true).excludePackage("p2").includePackage("p3").build()).build();
    Assert.assertEquals(expected, found);
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) Test(org.junit.Test)

Example 40 with ProvisioningConfig

use of org.jboss.galleon.config.ProvisioningConfig in project galleon by wildfly.

the class ProvisioningDiffProvider method getMergedConfig.

public ProvisioningConfig getMergedConfig() throws ProvisioningException {
    if (mergedConfig != null) {
        return mergedConfig;
    }
    if (!hasConfigChanges()) {
        mergedConfig = provisionedConfig;
        return provisionedConfig;
    }
    final ProvisioningConfig.Builder configBuilder = initProvisioningConfig();
    final Collection<ConfigModel> definedConfigs = provisionedConfig.getDefinedConfigs();
    if (!definedConfigs.isEmpty()) {
        for (ConfigModel originalConfig : definedConfigs) {
            final ConfigModel updatedConfig = updatedConfigs.remove(originalConfig.getId());
            if (updatedConfig != null) {
                configBuilder.addConfig(updatedConfig);
                continue;
            }
            if (removedConfigs.contains(originalConfig.getId())) {
                continue;
            }
            configBuilder.addConfig(originalConfig);
        }
    }
    if (!updatedConfigs.isEmpty()) {
        for (ConfigModel updatedConfig : updatedConfigs.values()) {
            configBuilder.addConfig(updatedConfig);
        }
    }
    if (!addedConfigs.isEmpty()) {
        for (ConfigModel addedConfig : addedConfigs.values()) {
            configBuilder.addConfig(addedConfig);
        }
    }
    if (!removedConfigs.isEmpty()) {
        List<ProvisionedConfig> baseConfigs = null;
        for (ConfigId configId : removedConfigs) {
            if (provisionedConfig.hasDefinedConfig(configId)) {
                if (baseConfigs == null) {
                    final ProvisioningConfig.Builder baseBuilder = initProvisioningConfig();
                    for (ProvisionedConfig config : provisionedState.getConfigs()) {
                        final ConfigId provisionedId = new ConfigId(config.getModel(), config.getName());
                        if (!provisionedConfig.hasDefinedConfig(provisionedId)) {
                            baseBuilder.excludeDefaultConfig(provisionedId);
                        }
                    }
                    try (ProvisioningRuntime baseRt = ProvisioningRuntimeBuilder.newInstance(log).initLayout(layout.getFactory(), baseBuilder.build()).build()) {
                        baseConfigs = baseRt.getConfigs();
                    }
                }
                if (getProvisionedConfig(baseConfigs, configId.getModel(), configId.getName()) != null) {
                    if (provisionedConfig.isInheritConfigs(true)) {
                        if (!provisionedConfig.isConfigModelExcluded(configId)) {
                            configBuilder.excludeDefaultConfig(configId);
                        }
                    } else if (provisionedConfig.isConfigModelIncluded(configId)) {
                        configBuilder.excludeDefaultConfig(configId);
                    }
                }
            } else if (provisionedConfig.isInheritConfigs(true)) {
                if (!provisionedConfig.isConfigModelExcluded(configId)) {
                    configBuilder.excludeDefaultConfig(configId);
                }
            } else if (provisionedConfig.isConfigModelIncluded(configId)) {
                configBuilder.excludeDefaultConfig(configId);
            }
        }
    }
    mergedConfig = configBuilder.build();
    return mergedConfig;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ConfigModel(org.jboss.galleon.config.ConfigModel) ProvisioningRuntime(org.jboss.galleon.runtime.ProvisioningRuntime) ConfigId(org.jboss.galleon.config.ConfigId) ProvisionedConfig(org.jboss.galleon.state.ProvisionedConfig)

Aggregations

ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)47 Test (org.junit.Test)16 Path (java.nio.file.Path)15 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)12 ProvisioningException (org.jboss.galleon.ProvisioningException)10 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)6 ProvisioningManager (org.jboss.galleon.ProvisioningManager)6 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)6 ConfigId (org.jboss.galleon.config.ConfigId)6 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)6 CommandException (org.aesh.command.CommandException)5 ConfigModel (org.jboss.galleon.config.ConfigModel)5 HashMap (java.util.HashMap)4 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)4 FeaturePackRuntimeBuilder (org.jboss.galleon.runtime.FeaturePackRuntimeBuilder)4 ProvisioningRuntime (org.jboss.galleon.runtime.ProvisioningRuntime)4 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)4 UniverseSpec (org.jboss.galleon.universe.UniverseSpec)4 HashSet (java.util.HashSet)3