Skip to content

Commit

Permalink
Merge pull request #182 from jfdenise/master
Browse files Browse the repository at this point in the history
Fix for GAL-202, Make passive the default when layers are installed
  • Loading branch information
aloubyansky authored Oct 29, 2018
2 parents 1648c1a + 23ddf56 commit 1ad4dd3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
5 changes: 5 additions & 0 deletions cli/src/main/java/org/jboss/galleon/cli/cmd/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -273,6 +274,10 @@ public void add(Node line) {
trees.add(line);
}

public void addAll(Collection<Node> nodes) {
trees.addAll(nodes);
}

public String build() {
builder = new StringBuilder();
columnsWidth.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.aesh.command.impl.internal.ProcessedOptionBuilder;
import org.aesh.command.parser.OptionParserException;
import org.aesh.readline.AeshContext;
import org.jboss.galleon.Constants;
import org.jboss.galleon.ProvisioningException;
import org.jboss.galleon.ProvisioningManager;
import org.jboss.galleon.ProvisioningOption;
Expand Down Expand Up @@ -139,6 +140,9 @@ protected void runCommand(PmCommandInvocation session, Map<String, String> optio
if (layers == null) {
manager.install(loc, options);
} else {
if (!options.containsKey(Constants.OPTIONAL_PACKAGES)) {
options.put(Constants.OPTIONAL_PACKAGES, Constants.PASSIVE);
}
manager.provision(new LayersConfigBuilder(pmSession, layers.split(","),
(String) getValue(MODEL_OPTION_NAME),
(String) getValue(CONFIG_OPTION_NAME), loc).build(), options);
Expand Down Expand Up @@ -213,7 +217,8 @@ protected List<ProcessedOption> getOtherOptions() throws OptionParserException {
hasValue(true).
type(String.class).
optionType(OptionType.NORMAL).
completer(LayersCompleter.class).
// Disable completion. Re-activate when layers show-up in WF.
//completer(LayersCompleter.class).
description(HelpDescriptions.INSTALL_LAYERS).
build();
options.add(layers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,13 @@ private static void displayPackage(PmCommandInvocation session, Group grp) throw
public static String buildConfigs(Map<String, List<ConfigInfo>> configs,
ProvisioningLayout<FeaturePackLayout> pLayout) throws ProvisioningException, IOException {
if (!configs.isEmpty()) {
boolean hasLayers = false;
List<Table.Node> nodes = new ArrayList<>();
Map<String, Map<String, Set<String>>> layers = LayersConfigBuilder.getAllLayers(pLayout);
Table.Tree table = new Table.Tree(Headers.CONFIGURATION, Headers.NAME, Headers.LAYERS);
for (Entry<String, List<ConfigInfo>> entry : configs.entrySet()) {
if (!entry.getValue().isEmpty()) {
Table.Node model = new Table.Node(entry.getKey());
table.add(model);
nodes.add(model);
for (ConfigInfo name : entry.getValue()) {
Table.Node nameNode = new Table.Node(name.getName());
model.addNext(nameNode);
Expand All @@ -325,20 +326,29 @@ public static String buildConfigs(Map<String, List<ConfigInfo>> configs,
}
}
if (!foundAsDependency) {
hasLayers = true;
nameNode.addNext(new Table.Node(id.getName()));
}
}
ConfigModel m = pLayout.getConfig().getDefinedConfig(name.getId());
if(m != null) {
if(m.hasExcludedLayers()) {
for(String ex : m.getExcludedLayers()) {
for (String ex : m.getExcludedLayers()) {
hasLayers = true;
nameNode.addNext(new Table.Node(ex+"(excluded)"));
}
}
}
}
}
}
Table.Tree table;
if (hasLayers) {
table = new Table.Tree(Headers.CONFIGURATION, Headers.NAME, Headers.LAYERS);
} else {
table = new Table.Tree(Headers.CONFIGURATION, Headers.NAME);
}
table.addAll(nodes);
return "Configurations" + Config.getLineSeparator() + table.build();
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.jboss.galleon.config.ConfigModel;
import org.jboss.galleon.config.FeaturePackConfig;
import org.jboss.galleon.config.ProvisioningConfig;
import org.jboss.galleon.maven.plugin.util.Config;
import org.jboss.galleon.maven.plugin.util.Configuration;
import org.jboss.galleon.maven.plugin.util.ConfigurationId;
import org.jboss.galleon.maven.plugin.util.FeaturePack;
import org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager;
Expand Down Expand Up @@ -119,7 +119,7 @@ public class ProvisionStateMojo extends AbstractMojo {
* A list of custom configurations to install.
*/
@Parameter(alias = "configurations", required = false)
private List<Config> configs = Collections.emptyList();
private List<Configuration> configs = Collections.emptyList();

/**
* Whether to use offline mode when the plugin resolves an artifact.
Expand Down Expand Up @@ -223,7 +223,7 @@ private void doProvision() throws MojoExecutionException, ProvisioningException
}

boolean hasLayers = false;
for (Config config : configs) {
for (Configuration config : configs) {
ConfigModel.Builder configBuilder = ConfigModel.
builder(config.getModel(), config.getName());
for (String layer : config.getLayers()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @author [email protected]
*/
public class Config {
public class Configuration {

private String model;
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.nio.file.Path;
import java.util.Arrays;
import org.aesh.command.CommandException;
import org.jboss.galleon.Constants;
import org.jboss.galleon.ProvisioningManager;
import static org.jboss.galleon.cli.CliTestUtils.PRODUCER1;
import static org.jboss.galleon.cli.CliTestUtils.UNIVERSE_NAME;
Expand All @@ -29,6 +30,7 @@
import org.jboss.galleon.universe.MvnUniverse;
import org.jboss.galleon.universe.UniverseSpec;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -97,6 +99,9 @@ public void test() throws Exception {
assertTrue(conf.getIncludedLayers().size() == 2);
assertTrue(conf.getIncludedLayers().contains("layerA-" + PRODUCER1));
assertTrue(conf.getIncludedLayers().contains("layerC-" + PRODUCER1));
String opt = config.getPluginOption(Constants.OPTIONAL_PACKAGES);
assertNotNull(opt);
assertEquals(Constants.PASSIVE, opt);

cli.execute("get-info --dir=" + path + " --type=configs");
assertTrue(cli.getOutput(), cli.getOutput().contains("layerA-" + PRODUCER1));
Expand Down

0 comments on commit 1ad4dd3

Please sign in to comment.