From 1fb01a44b2562c5c2f675ed809803db4d4fda30d Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Tue, 19 Mar 2024 14:08:44 +0100 Subject: [PATCH] Support package and config stability --- .../wildfly/glow/cli/commands/Constants.java | 6 ++++++ .../glow/cli/commands/ScanCommand.java | 21 ++++++++++++++++++- .../main/resources/UsageMessages.properties | 4 +++- .../main/java/org/wildfly/glow/Arguments.java | 18 +++++++++++----- .../wildfly/glow/BaseArgumentsBuilder.java | 6 ++++-- .../java/org/wildfly/glow/GlowSession.java | 21 ++++++++++++------- .../java/org/wildfly/glow/ScanArguments.java | 11 +++++++--- .../org/wildfly/glow/ScanResultsPrinter.java | 20 ++++++++++++------ pom.xml | 4 ++-- 9 files changed, 83 insertions(+), 28 deletions(-) diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/Constants.java b/cli/src/main/java/org/wildfly/glow/cli/commands/Constants.java index 02d2a180..4978cf23 100644 --- a/cli/src/main/java/org/wildfly/glow/cli/commands/Constants.java +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/Constants.java @@ -92,5 +92,11 @@ public interface Constants { String STABILITY_OPTION = "--stability-level"; String STABILITY_OPTION_SHORT = "-sl"; + String PACKAGE_STABILITY_OPTION = "--package-stability-level"; + String PACKAGE_STABILITY_OPTION_SHORT = "-psl"; + + String CONFIG_STABILITY_OPTION = "--config-stability-level"; + String CONFIG_STABILITY_OPTION_SHORT = "-csl"; + String STABILITY_LABEL = ""; } diff --git a/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java b/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java index f6dd5958..56d614b4 100644 --- a/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java +++ b/cli/src/main/java/org/wildfly/glow/cli/commands/ScanCommand.java @@ -111,6 +111,12 @@ public Stability convert(String value) throws Exception { @CommandLine.Option(converter = StabilityConverter.class, names = {Constants.STABILITY_OPTION, Constants.STABILITY_OPTION_SHORT}, paramLabel = Constants.STABILITY_LABEL) Optional stability; + @CommandLine.Option(converter = StabilityConverter.class, names = {Constants.PACKAGE_STABILITY_OPTION, Constants.PACKAGE_STABILITY_OPTION_SHORT}, paramLabel = Constants.STABILITY_LABEL) + Optional packageStability; + + @CommandLine.Option(converter = StabilityConverter.class, names = {Constants.CONFIG_STABILITY_OPTION, Constants.CONFIG_STABILITY_OPTION_SHORT}, paramLabel = Constants.STABILITY_LABEL) + Optional configStability; + @CommandLine.Option(names = {Constants.ENV_FILE_OPTION_SHORT, Constants.ENV_FILE_OPTION}, paramLabel = Constants.ENV_FILE_OPTION_LABEL) Optional envFile; @@ -208,7 +214,20 @@ public Integer call() throws Exception { } builder.setExcludeArchivesFromScan(excludeArchivesFromScan); if (stability.isPresent()) { - builder.setStability(stability.get()); + 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"); + } + builder.setConfigStability(stability.get()); + builder.setPackageStability(stability.get()); + } + if (configStability.isPresent()) { + builder.setConfigStability(configStability.get()); + } + if (packageStability.isPresent()) { + builder.setPackageStability(packageStability.get()); } if (dockerImageName.isPresent()) { if (provision.isPresent() && !DOCKER_IMAGE.equals(provision.get())) { diff --git a/cli/src/main/resources/UsageMessages.properties b/cli/src/main/resources/UsageMessages.properties index 5630dae7..eb401acd 100644 --- a/cli/src/main/resources/UsageMessages.properties +++ b/cli/src/main/resources/UsageMessages.properties @@ -34,7 +34,9 @@ input-feature-packs-file = Galleon feature-packs used by wildfly-glow are retrie provision = The kind of provisioning to produce based on what has been discovered. Can be @|fg(yellow) SERVER|@: a provisioned WildFly server, @|fg(yellow) BOOTABLE_JAR|@: a WildFly Bootable JAR, @|fg(yellow) DOCKER_IMAGE|@: a Docker image, @|fg(yellow) OPENSHIFT|@: a server built and deploy on OpenShift, you must be logged to a cluster, or @|fg(yellow) PROVISIONING_XML|@: a Galleon provisioning.xml file. output-dir = If specifying to provision, the directory where the result will be output. wildfly-preview = Use only WildFly preview feature-packs as input. -stability-level = Specify a stability to be used when provisioning a server. The stability is also used to identify server features that would be not enabled by the specified stability. The stability is by default the minimum stability of each Galleon feature-packs. The stability can be @|fg(yellow) default|@, @|fg(yellow) community|@, @|fg(yellow) preview|@, @|fg(yellow) experimental|@. +stability-level = Specify a stability to be used when provisioning a server. This is an option to set both config-stability-level and package-stability-level options with a single option. The stability is also used to identify server features and packages that would be not enabled by the specified stability. The stability is by default the minimum stability of each Galleon feature-packs. The stability can be @|fg(yellow) default|@, @|fg(yellow) community|@, @|fg(yellow) preview|@, @|fg(yellow) experimental|@. +config-stability-level = Specify a stability to be used when provisioning the server configuration. The stability is also used to identify server features that would be not enabled by the specified stability. The stability is by default the minimum stability of each Galleon feature-packs. The stability can be @|fg(yellow) default|@, @|fg(yellow) community|@, @|fg(yellow) preview|@, @|fg(yellow) experimental|@. +package-stability-level = Specify a stability to be used when provisioning server packages. The stability is also used to identify server packages that would be not provisioned by the specified stability. The stability is by default the minimum stability of each Galleon feature-packs. The stability can be @|fg(yellow) default|@, @|fg(yellow) community|@, @|fg(yellow) preview|@, @|fg(yellow) experimental|@. env-file = The path to a file that contains environment variables (in the form env=value) to be passed to the OpenShift deployment. Can only be used with @|fg(yellow) OPENSHIFT|@ kind of provisioning. init-script = The path to a script that contains commands (JBoss CLI, add-user, ...) to fine tune the server on OpenShift deployment. Can only be used with @|fg(yellow) OPENSHIFT|@ kind of provisioning. diff --git a/core/src/main/java/org/wildfly/glow/Arguments.java b/core/src/main/java/org/wildfly/glow/Arguments.java index d8124cbb..c1b41742 100644 --- a/core/src/main/java/org/wildfly/glow/Arguments.java +++ b/core/src/main/java/org/wildfly/glow/Arguments.java @@ -33,7 +33,8 @@ public class Arguments implements GoOfflineArguments, ScanArguments { private final boolean verbose; private final boolean techPreview; private final Set excludeArchivesFromScan; - private final Stability stability; + private final Stability configStability; + private final Stability packageStability; protected Arguments( String executionContext, @@ -49,7 +50,8 @@ protected Arguments( boolean verbose, boolean techPreview, Set excludeArchivesFromScan, - Stability stability) { + Stability configStability, + Stability packageStability) { this.executionProfiles = executionProfiles; this.userEnabledAddOns = userEnabledAddOns; this.binaries = binaries; @@ -63,7 +65,8 @@ protected Arguments( this.verbose = verbose; this.techPreview = techPreview; this.excludeArchivesFromScan = excludeArchivesFromScan; - this.stability = stability; + this.configStability = configStability; + this.packageStability = packageStability; HiddenPropertiesAccessor hiddenPropertiesAccessor = new HiddenPropertiesAccessor(); this.compact = Boolean.parseBoolean(hiddenPropertiesAccessor.getProperty(COMPACT_PROPERTY)); @@ -179,8 +182,13 @@ public Set getExcludeArchivesFromScan() { } @Override - public Stability getStability() { - return stability; + public Stability getConfigStability() { + return configStability; + } + + @Override + public Stability getPackageStability() { + return packageStability; } static GoOfflineArguments.Builder goOfflineBuilder() { diff --git a/core/src/main/java/org/wildfly/glow/BaseArgumentsBuilder.java b/core/src/main/java/org/wildfly/glow/BaseArgumentsBuilder.java index 4d2c44b0..53f7a8fb 100644 --- a/core/src/main/java/org/wildfly/glow/BaseArgumentsBuilder.java +++ b/core/src/main/java/org/wildfly/glow/BaseArgumentsBuilder.java @@ -40,7 +40,8 @@ public class BaseArgumentsBuilder { protected boolean techPreview; protected Set excludeJarsFromScan = Collections.emptySet(); - protected Stability stability; + protected Stability packageStability; + protected Stability configStability; protected BaseArgumentsBuilder() { @@ -65,6 +66,7 @@ public Arguments build() { verbose, techPreview, excludeJarsFromScan, - stability); + configStability, + packageStability); } } diff --git a/core/src/main/java/org/wildfly/glow/GlowSession.java b/core/src/main/java/org/wildfly/glow/GlowSession.java index bad872dc..2b1c20f5 100644 --- a/core/src/main/java/org/wildfly/glow/GlowSession.java +++ b/core/src/main/java/org/wildfly/glow/GlowSession.java @@ -482,10 +482,10 @@ public ScanResults scan() throws Exception { } // Identify the active feature-packs. GalleonProvisioningConfig activeConfig = buildProvisioningConfig(config, - universeResolver, allBaseLayers, baseLayer, decorators, excludedLayers, fpDependencies, arguments.getConfigName(), arguments.getStability()); + universeResolver, allBaseLayers, baseLayer, decorators, excludedLayers, fpDependencies, arguments.getConfigName(), arguments.getConfigStability(), arguments.getPackageStability()); // Handle stability - if (arguments.getStability() != null) { + if (arguments.getConfigStability() != null) { List checkLayers = new ArrayList<>(); checkLayers.add(baseLayer); checkLayers.addAll(decorators); @@ -504,7 +504,7 @@ public ScanResults scan() throws Exception { List lst = rt.getAllFeatures(); for (GalleonFeatureSpec spec : lst) { Stability stab = spec.getStability() == null ? null : Stability.fromString(spec.getStability()); - if (stab != null && !arguments.getStability().enables(stab)) { + if (stab != null && !arguments.getConfigStability().enables(stab)) { Set set = excludedFeatures.get(layer); if (set == null) { set = new HashSet<>(); @@ -514,7 +514,7 @@ public ScanResults scan() throws Exception { } for (GalleonFeatureParamSpec pspec : spec.getParams()) { Stability pstab = pspec.getStability() == null ? null : Stability.fromString(pspec.getStability()); - if (pstab != null && !arguments.getStability().enables(pstab)) { + if (pstab != null && !arguments.getConfigStability().enables(pstab)) { Set set = excludedFeatures.get(layer); if (set == null) { set = new HashSet<>(); @@ -529,13 +529,15 @@ public ScanResults scan() throws Exception { writer.warn("Got unexpected exception dealing with " + layer + " features. Exception" + ex +". Please report the issue."); } } + } + 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(); 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.getStability().enables(packageStability)) { + if (packageStability != null && !arguments.getPackageStability().enables(packageStability)) { excludedPackages.add(prt.getName() + "[stability="+packageStability.toString()+"]"); } } @@ -907,7 +909,7 @@ private static GalleonProvisioningConfig buildProvisioningConfig(GalleonProvisio Set decorators, Set excludedLayers, Map> fpDependencies, - String configName, Stability stability) throws ProvisioningException { + String configName, Stability configStability, Stability packageStability) throws ProvisioningException { Map map = new HashMap<>(); Map universeToGav = new HashMap<>(); for (GalleonFeaturePackConfig cfg : input.getFeaturePackDeps()) { @@ -990,8 +992,11 @@ private static GalleonProvisioningConfig buildProvisioningConfig(GalleonProvisio Map options = new HashMap<>(); options.put(Constants.OPTIONAL_PACKAGES, Constants.PASSIVE_PLUS); options.put("jboss-fork-embedded", "true"); - if (stability != null) { - options.put(Constants.STABILITY_LEVEL, stability.toString()); + if (configStability != null) { + options.put(Constants.CONFIG_STABILITY_LEVEL, configStability.toString()); + } + if (packageStability != null) { + options.put(Constants.PACKAGE_STABILITY_LEVEL, packageStability.toString()); } activeConfigBuilder.addOptions(options); return activeConfigBuilder.build(); diff --git a/core/src/main/java/org/wildfly/glow/ScanArguments.java b/core/src/main/java/org/wildfly/glow/ScanArguments.java index 7ef48343..83fcce44 100644 --- a/core/src/main/java/org/wildfly/glow/ScanArguments.java +++ b/core/src/main/java/org/wildfly/glow/ScanArguments.java @@ -74,7 +74,8 @@ public interface ScanArguments { Set getExcludeArchivesFromScan(); - Stability getStability(); + Stability getConfigStability(); + Stability getPackageStability(); default Builder createScanArgumentsBuilder() { return new Builder(); @@ -154,8 +155,12 @@ public Builder setExcludeArchivesFromScan(Set archives) { return this; } - public Builder setStability(Stability stability) { - this.stability = stability; + public Builder setPackageStability(Stability stability) { + this.packageStability = stability; + return this; + } + public Builder setConfigStability(Stability stability) { + this.configStability = stability; return this; } } diff --git a/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java b/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java index 34d43524..c2531e7e 100644 --- a/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java +++ b/core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java @@ -80,8 +80,11 @@ private void detailed(ScanArguments arguments, ScanResults scanResults) throws E profileBuilder.append("none"); } writer.info(profileBuilder); - if(arguments.getStability() != null) { - writer.info("stability: " + arguments.getStability().toString()); + if(arguments.getConfigStability() != null) { + writer.info("config stability: " + arguments.getConfigStability().toString()); + } + if(arguments.getPackageStability() != null) { + writer.info("package stability: " + arguments.getPackageStability().toString()); } writer.info("galleon discovery"); StringBuilder builder = new StringBuilder(); @@ -134,11 +137,16 @@ private void detailed(ScanArguments arguments, ScanResults scanResults) throws E } writer.info(disabledBuilder); } - if (arguments.getStability() != null) { + if (arguments.getConfigStability() != null || arguments.getPackageStability() != null) { boolean needCR = false; - if (!scanResults.getExcludedFeatures().isEmpty() || !scanResults.getExcludedPackages().isEmpty()) { - writer.info("The following features and/or packages would be disabled if provisioning a server at the '" - + arguments.getStability().toString() + "' stability level:"); + if (!scanResults.getExcludedFeatures().isEmpty()) { + writer.info("The following features would be disabled if provisioning a server at the '" + + arguments.getConfigStability().toString() + "' stability level for configs:"); + needCR = true; + } + if(!scanResults.getExcludedPackages().isEmpty()) { + writer.info("The following packages would be disabled if provisioning a server at the '" + + arguments.getPackageStability().toString() + "' stability level for packages:"); needCR = true; } if (!scanResults.getExcludedFeatures().isEmpty()) { diff --git a/pom.xml b/pom.xml index e3305245..517542b0 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 3.8.6 3.0.0 1.6.3 - 6.0.0.Beta3 + 6.0.0.Beta4 1.0.5.Final 24.0.0.Beta1 1.2.1.Final @@ -57,7 +57,7 @@ true - 7.0.0.Beta3 + 7.0.0.Beta5 2.1.1 4.0.1 4.0.1