Skip to content

Commit

Permalink
Some stability and WildFly 32 Beta1 related fixes. Removed dependency…
Browse files Browse the repository at this point in the history
… on wildfly-core
  • Loading branch information
Jean Francois Denise committed Apr 11, 2024
1 parent bb753d6 commit 9f17b55
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.wildfly.glow.cli;

import java.lang.reflect.InvocationTargetException;
import org.wildfly.glow.cli.commands.AbstractCommand;
import picocli.CommandLine;

Expand All @@ -37,7 +38,11 @@ public ExecutionExceptionHandler(boolean isVerbose, AbstractCommand command) {
@Override
public int handleExecutionException(Exception ex, CommandLine commandLine, CommandLine.ParseResult parseResult)
throws Exception {
command.printError("ERROR: %s", ex.getLocalizedMessage());
String msg = ex.getLocalizedMessage();
if (ex instanceof InvocationTargetException) {
msg = ex.getCause().getLocalizedMessage();
}
command.printError("ERROR: %s", msg);
if(isVerbose) {
ex.printStackTrace(command.getStderr());
}
Expand Down
42 changes: 25 additions & 17 deletions cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.jboss.as.version.Stability;
import org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec;
import org.jboss.galleon.universe.maven.repo.MavenRepoManager;
import org.wildfly.channel.ChannelSession;
Expand All @@ -55,6 +55,7 @@
import static org.wildfly.glow.OutputFormat.BOOTABLE_JAR;
import static org.wildfly.glow.OutputFormat.DOCKER_IMAGE;
import static org.wildfly.glow.OutputFormat.OPENSHIFT;
import org.wildfly.glow.StabilitySupport;
import org.wildfly.glow.maven.ChannelMavenArtifactRepositoryManager;

@CommandLine.Command(
Expand All @@ -63,13 +64,6 @@
)
public class ScanCommand extends AbstractCommand {

private static class StabilityConverter implements CommandLine.ITypeConverter<Stability> {

@Override
public Stability convert(String value) throws Exception {
return Stability.fromString(value);
}
}
private static class ProvisionConverter implements CommandLine.ITypeConverter<OutputFormat> {

@Override
Expand Down Expand Up @@ -122,14 +116,14 @@ public OutputFormat convert(String value) throws Exception {
split = ",", paramLabel = Constants.EXCLUDE_ARCHIVES_FROM_SCAN_OPTION_LABEL)
Set<String> excludeArchivesFromScan = new HashSet<>();

@CommandLine.Option(converter = StabilityConverter.class, names = {Constants.STABILITY_OPTION, Constants.STABILITY_OPTION_SHORT}, paramLabel = Constants.STABILITY_LABEL)
Optional<Stability> stability;
@CommandLine.Option(names = {Constants.STABILITY_OPTION, Constants.STABILITY_OPTION_SHORT}, paramLabel = Constants.STABILITY_LABEL)
Optional<String> stability;

@CommandLine.Option(converter = StabilityConverter.class, names = {Constants.PACKAGE_STABILITY_OPTION, Constants.PACKAGE_STABILITY_OPTION_SHORT}, paramLabel = Constants.STABILITY_LABEL)
Optional<Stability> packageStability;
@CommandLine.Option(names = {Constants.PACKAGE_STABILITY_OPTION, Constants.PACKAGE_STABILITY_OPTION_SHORT}, paramLabel = Constants.STABILITY_LABEL)
Optional<String> packageStability;

@CommandLine.Option(converter = StabilityConverter.class, names = {Constants.CONFIG_STABILITY_OPTION, Constants.CONFIG_STABILITY_OPTION_SHORT}, paramLabel = Constants.STABILITY_LABEL)
Optional<Stability> configStability;
@CommandLine.Option(names = {Constants.CONFIG_STABILITY_OPTION, Constants.CONFIG_STABILITY_OPTION_SHORT}, paramLabel = Constants.STABILITY_LABEL)
Optional<String> configStability;

@CommandLine.Option(names = {Constants.ENV_FILE_OPTION_SHORT, Constants.ENV_FILE_OPTION}, paramLabel = Constants.ENV_FILE_OPTION_LABEL)
Optional<Path> envFile;
Expand Down Expand Up @@ -289,20 +283,29 @@ public Integer call() throws Exception {
builder.setExecutionContext(CLOUD_EXECUTION_CONTEXT);
}
builder.setExcludeArchivesFromScan(excludeArchivesFromScan);

// Enforce community stability level. Doing so, any discovered features at a lower level are advertised
String userSetConfigStability = null;
builder.setConfigStability(org.jboss.galleon.Constants.STABILITY_COMMUNITY);
if (stability.isPresent()) {
if (configStability.isPresent()) {
throw new Exception(Constants.CONFIG_STABILITY_OPTION + " can't be set when " + Constants.STABILITY_OPTION + " is set");
}
if (packageStability.isPresent()) {
throw new Exception(Constants.PACKAGE_STABILITY_OPTION + " can't be set when " + Constants.STABILITY_OPTION + " is set");
}
StabilitySupport.checkStability(stability.get());
userSetConfigStability = stability.get();
builder.setConfigStability(stability.get());
builder.setPackageStability(stability.get());
}
if (configStability.isPresent()) {
StabilitySupport.checkStability(configStability.get());
userSetConfigStability = configStability.get();
builder.setConfigStability(configStability.get());
}
if (packageStability.isPresent()) {
StabilitySupport.checkStability(packageStability.get());
builder.setPackageStability(packageStability.get());
}
if (dockerImageName.isPresent()) {
Expand All @@ -316,7 +319,7 @@ public Integer call() throws Exception {
ConfigurationResolver configurationResolver = new ConfigurationResolver() {
@Override
public ResolvedEnvs getResolvedEnvs(Layer layer, Set<Env> input) throws Exception {
if(provision.get().equals(OPENSHIFT)) {
if(provision.isPresent() && provision.get().equals(OPENSHIFT)) {
return OpenShiftSupport.getResolvedEnvs(layer, input, disableDeployers);
}
return null;
Expand Down Expand Up @@ -435,7 +438,7 @@ public ResolvedEnvs getResolvedEnvs(Layer layer, Set<Env> input) throws Exceptio
if (cloud.orElse(false)) {
completedMessage = "@|bold To run the server call: 'JBOSS_HOME=" + rel + " sh " + rel + "/bin/openshift-launch.sh'|@";
} else {
completedMessage = "@|bold To run the server call: 'sh " + rel + "/bin/standalone.sh'|@";
completedMessage = "@|bold To run the server call: 'sh " + rel + "/bin/standalone.sh" + (userSetConfigStability == null ? "" : " --stability=" + userSetConfigStability) + "'|@";
}
break;
}
Expand All @@ -456,6 +459,9 @@ public ResolvedEnvs getResolvedEnvs(Layer layer, Set<Env> input) throws Exceptio
envMap.put(env.getName(), env.getDescription());
}
}
// We need the latest plugin,
// To be removed once WildFly Maven Plugin is released.
buildExtraEnv.put("PROVISIONING_MAVEN_PLUGIN_VERSION", "5.0.0.Beta5");
OpenShiftSupport.deploy(GlowMessageWriter.DEFAULT,
target, name.isEmpty() ? "app-from-glow" : name.toLowerCase(),
envMap,
Expand All @@ -469,7 +475,9 @@ public ResolvedEnvs getResolvedEnvs(Layer layer, Set<Env> input) throws Exceptio
initScriptFile.orElse(null),
cliScriptFile.orElse(null),
new OpenShiftConfiguration.Builder().build(),
directMavenResolver);
directMavenResolver,
userSetConfigStability,
Collections.emptyMap());
print("@|bold \nOpenshift build and deploy DONE.|@");
} else {
if (content.getDockerImageName() != null) {
Expand Down
4 changes: 0 additions & 4 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
<groupId>org.jboss.galleon</groupId>
<artifactId>galleon-api</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-version</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.channel</groupId>
<artifactId>channel-core</artifactId>
Expand Down
13 changes: 6 additions & 7 deletions core/src/main/java/org/wildfly/glow/Arguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import org.jboss.as.version.Stability;
import org.wildfly.channel.ChannelSession;

public class Arguments implements GoOfflineArguments, ScanArguments {
Expand All @@ -34,8 +33,8 @@ public class Arguments implements GoOfflineArguments, ScanArguments {
private final boolean verbose;
private final boolean techPreview;
private final Set<Pattern> excludeArchivesFromScan;
private final Stability configStability;
private final Stability packageStability;
private final String configStability;
private final String packageStability;
private final boolean isCli;
private final ChannelSession channelSession;

Expand All @@ -53,8 +52,8 @@ protected Arguments(
boolean verbose,
boolean techPreview,
Set<Pattern> excludeArchivesFromScan,
Stability configStability,
Stability packageStability,
String configStability,
String packageStability,
boolean isCli,
ChannelSession channelSession) {
this.executionProfiles = executionProfiles;
Expand Down Expand Up @@ -189,12 +188,12 @@ public Set<Pattern> getExcludeArchivesFromScan() {
}

@Override
public Stability getConfigStability() {
public String getConfigStability() {
return configStability;
}

@Override
public Stability getPackageStability() {
public String getPackageStability() {
return packageStability;
}

Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/org/wildfly/glow/BaseArgumentsBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.jboss.as.version.Stability;
import org.wildfly.channel.ChannelSession;

public class BaseArgumentsBuilder {
Expand All @@ -41,8 +40,8 @@ public class BaseArgumentsBuilder {
protected boolean techPreview;

protected Set<String> excludeJarsFromScan = Collections.emptySet();
protected Stability packageStability;
protected Stability configStability;
protected String packageStability;
protected String configStability;
protected boolean isCli;
protected ChannelSession channelSession;

Expand Down
31 changes: 18 additions & 13 deletions core/src/main/java/org/wildfly/glow/GlowSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import org.jboss.as.version.Stability;
import org.jboss.galleon.MessageWriter;
import org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec;
import static org.wildfly.glow.OutputFormat.BOOTABLE_JAR;
Expand Down Expand Up @@ -153,16 +152,17 @@ public ScanResults scan() throws Exception {
provider.addArtifactResolver(resolver);
Provisioning provisioning = null;
GalleonProvisioningConfig config = Utils.buildOfflineProvisioningConfig(provider, writer);
Path fakeHome = Files.createTempDirectory("wildfly-glow");
try {
if (config == null) {
Path provisioningXML = arguments.getProvisioningXML();
if (provisioningXML == null) {
provisioningXML = FeaturePacks.getFeaturePacks(arguments.getVersion(), arguments.getExecutionContext(), arguments.isTechPreview());
}
provisioning = provider.newProvisioningBuilder(provisioningXML).build();
provisioning = provider.newProvisioningBuilder(provisioningXML).setInstallationHome(fakeHome).build();
config = provisioning.loadProvisioningConfig(provisioningXML);
} else {
provisioning = provider.newProvisioningBuilder(config).build();
provisioning = provider.newProvisioningBuilder(config).setInstallationHome(fakeHome).build();
}
GalleonProvisioningConfig inputConfig = config;
// Channel handling
Expand Down Expand Up @@ -539,7 +539,7 @@ public ScanResults scan() throws Exception {
for (Layer layer : checkLayers) {
try {
GalleonConfigurationWithLayers configLayers = GalleonConfigurationWithLayersBuilder.builder("standalone", "standalone.xml").includeLayer(layer.getName()).build();
GalleonProvisioningConfig.Builder config2Builder = GalleonProvisioningConfig.builder().addConfig(configLayers);
GalleonProvisioningConfig.Builder config2Builder = GalleonProvisioningConfig.builder().addConfig(configLayers).addOption(Constants.CONFIG_STABILITY_LEVEL, Constants.STABILITY_EXPERIMENTAL);
for (GalleonFeaturePackConfig fp : activeConfig.getFeaturePackDeps()) {
config2Builder.addFeaturePackDep(GalleonFeaturePackConfig.
builder(fp.getLocation(), false).setInheritConfigs(false).build());
Expand All @@ -549,8 +549,8 @@ public ScanResults scan() throws Exception {
try (GalleonProvisioningRuntime rt = provisioning.getProvisioningRuntime(config2)) {
List<GalleonFeatureSpec> lst = rt.getAllFeatures();
for (GalleonFeatureSpec spec : lst) {
Stability stab = spec.getStability() == null ? null : Stability.fromString(spec.getStability());
if (stab != null && !arguments.getConfigStability().enables(stab)) {
String stab = spec.getStability();
if (stab != null && !StabilitySupport.enables(arguments.getConfigStability(), stab)) {
Set<String> set = excludedFeatures.get(layer);
if (set == null) {
set = new HashSet<>();
Expand All @@ -559,8 +559,8 @@ public ScanResults scan() throws Exception {
set.add(spec.getName() + "[stability=" + spec.getStability() + "]");
}
for (GalleonFeatureParamSpec pspec : spec.getParams()) {
Stability pstab = pspec.getStability() == null ? null : Stability.fromString(pspec.getStability());
if (pstab != null && !arguments.getConfigStability().enables(pstab)) {
String pstab = pspec.getStability();
if (pstab != null && !StabilitySupport.enables(arguments.getConfigStability(), pstab)) {
Set<String> set = excludedFeatures.get(layer);
if (set == null) {
set = new HashSet<>();
Expand All @@ -578,13 +578,17 @@ public ScanResults scan() throws Exception {
}
if(arguments.getPackageStability() != null) {
// We must disable the stability to see all packages in the runtime
GalleonProvisioningConfig config2 = GalleonProvisioningConfig.builder(activeConfig).removeOption(Constants.STABILITY_LEVEL).build();
GalleonProvisioningConfig config2 = GalleonProvisioningConfig.builder(activeConfig).
removeOption(Constants.STABILITY_LEVEL).
removeOption(Constants.CONFIG_STABILITY_LEVEL).
removeOption(Constants.PACKAGE_STABILITY_LEVEL).
addOption(Constants.STABILITY_LEVEL, arguments.getConfigStability() == null ? Constants.STABILITY_EXPERIMENTAL : arguments.getConfigStability()).build();
try (GalleonProvisioningRuntime rt = provisioning.getProvisioningRuntime(config2)) {
for (GalleonFeaturePackRuntime fpr : rt.getGalleonFeaturePacks()) {
for (GalleonPackageRuntime prt : fpr.getGalleonPackages()) {
Stability packageStability = prt.getStability() == null ? null : Stability.fromString(prt.getStability());
if (packageStability != null && !arguments.getPackageStability().enables(packageStability)) {
excludedPackages.add(prt.getName() + "[stability="+packageStability.toString()+"]");
String packageStability = prt.getStability();
if (packageStability != null && !StabilitySupport.enables(arguments.getPackageStability(), packageStability)) {
excludedPackages.add(prt.getName() + "[stability="+packageStability+"]");
}
}
}
Expand Down Expand Up @@ -613,6 +617,7 @@ public ScanResults scan() throws Exception {
return scanResults;
} finally {
IoUtils.recursiveDelete(OFFLINE_CONTENT);
IoUtils.recursiveDelete(fakeHome);
}
}

Expand Down Expand Up @@ -949,7 +954,7 @@ private static GalleonProvisioningConfig buildProvisioningConfig(GalleonProvisio
Set<Layer> decorators,
Set<Layer> excludedLayers,
Map<FeaturePackLocation.FPID, Set<FeaturePackLocation.ProducerSpec>> fpDependencies,
String configName, Stability configStability, Stability packageStability) throws ProvisioningException {
String configName, String configStability, String packageStability) throws ProvisioningException {
Map<ProducerSpec, GalleonFeaturePackConfig> map = new HashMap<>();
Map<ProducerSpec, FPID> universeToGav = new HashMap<>();
for (GalleonFeaturePackConfig cfg : input.getFeaturePackDeps()) {
Expand Down
9 changes: 4 additions & 5 deletions core/src/main/java/org/wildfly/glow/ScanArguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import org.jboss.as.version.Stability;
import org.wildfly.channel.ChannelSession;

public interface ScanArguments {
Expand Down Expand Up @@ -75,8 +74,8 @@ public interface ScanArguments {

Set<Pattern> getExcludeArchivesFromScan();

Stability getConfigStability();
Stability getPackageStability();
String getConfigStability();
String getPackageStability();
boolean isCli();
ChannelSession getChannelSession();

Expand Down Expand Up @@ -158,11 +157,11 @@ public Builder setExcludeArchivesFromScan(Set<String> archives) {
return this;
}

public Builder setPackageStability(Stability stability) {
public Builder setPackageStability(String stability) {
this.packageStability = stability;
return this;
}
public Builder setConfigStability(Stability stability) {
public Builder setConfigStability(String stability) {
this.configStability = stability;
return this;
}
Expand Down
Loading

0 comments on commit 9f17b55

Please sign in to comment.