Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support package and config stability #53

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<default|community|preview|experimental>";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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> 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(converter = StabilityConverter.class, names = {Constants.CONFIG_STABILITY_OPTION, Constants.CONFIG_STABILITY_OPTION_SHORT}, paramLabel = Constants.STABILITY_LABEL)
Optional<Stability> 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 @@ -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())) {
Expand Down
4 changes: 3 additions & 1 deletion cli/src/main/resources/UsageMessages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
18 changes: 13 additions & 5 deletions core/src/main/java/org/wildfly/glow/Arguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class Arguments implements GoOfflineArguments, ScanArguments {
private final boolean verbose;
private final boolean techPreview;
private final Set<Pattern> excludeArchivesFromScan;
private final Stability stability;
private final Stability configStability;
private final Stability packageStability;

protected Arguments(
String executionContext,
Expand All @@ -49,7 +50,8 @@ protected Arguments(
boolean verbose,
boolean techPreview,
Set<Pattern> excludeArchivesFromScan,
Stability stability) {
Stability configStability,
Stability packageStability) {
this.executionProfiles = executionProfiles;
this.userEnabledAddOns = userEnabledAddOns;
this.binaries = binaries;
Expand All @@ -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));
Expand Down Expand Up @@ -179,8 +182,13 @@ public Set<Pattern> getExcludeArchivesFromScan() {
}

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

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

static GoOfflineArguments.Builder goOfflineBuilder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public class BaseArgumentsBuilder {
protected boolean techPreview;

protected Set<String> excludeJarsFromScan = Collections.emptySet();
protected Stability stability;
protected Stability packageStability;
protected Stability configStability;

protected BaseArgumentsBuilder() {

Expand All @@ -65,6 +66,7 @@ public Arguments build() {
verbose,
techPreview,
excludeJarsFromScan,
stability);
configStability,
packageStability);
}
}
21 changes: 13 additions & 8 deletions core/src/main/java/org/wildfly/glow/GlowSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Layer> checkLayers = new ArrayList<>();
checkLayers.add(baseLayer);
checkLayers.addAll(decorators);
Expand All @@ -504,7 +504,7 @@ public ScanResults scan() throws Exception {
List<GalleonFeatureSpec> 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<String> set = excludedFeatures.get(layer);
if (set == null) {
set = new HashSet<>();
Expand All @@ -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<String> set = excludedFeatures.get(layer);
if (set == null) {
set = new HashSet<>();
Expand All @@ -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()+"]");
}
}
Expand Down Expand Up @@ -907,7 +909,7 @@ private static GalleonProvisioningConfig buildProvisioningConfig(GalleonProvisio
Set<Layer> decorators,
Set<Layer> excludedLayers,
Map<FeaturePackLocation.FPID, Set<FeaturePackLocation.ProducerSpec>> fpDependencies,
String configName, Stability stability) throws ProvisioningException {
String configName, Stability configStability, Stability packageStability) throws ProvisioningException {
Map<FPID, GalleonFeaturePackConfig> map = new HashMap<>();
Map<FPID, FPID> universeToGav = new HashMap<>();
for (GalleonFeaturePackConfig cfg : input.getFeaturePackDeps()) {
Expand Down Expand Up @@ -990,8 +992,11 @@ private static GalleonProvisioningConfig buildProvisioningConfig(GalleonProvisio
Map<String, String> 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();
Expand Down
11 changes: 8 additions & 3 deletions core/src/main/java/org/wildfly/glow/ScanArguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public interface ScanArguments {

Set<Pattern> getExcludeArchivesFromScan();

Stability getStability();
Stability getConfigStability();
Stability getPackageStability();

default Builder createScanArgumentsBuilder() {
return new Builder();
Expand Down Expand Up @@ -154,8 +155,12 @@ public Builder setExcludeArchivesFromScan(Set<String> 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;
}
}
Expand Down
20 changes: 14 additions & 6 deletions core/src/main/java/org/wildfly/glow/ScanResultsPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<version.org.apache.maven>3.8.6</version.org.apache.maven>
<version.org.apache.maven.checkstyle>3.0.0</version.org.apache.maven.checkstyle>
<version.org.apache.maven.resolver>1.6.3</version.org.apache.maven.resolver>
<version.org.jboss.galleon>6.0.0.Beta3</version.org.jboss.galleon>
<version.org.jboss.galleon>6.0.0.Beta4</version.org.jboss.galleon>
<version.org.wildfly.channel>1.0.5.Final</version.org.wildfly.channel>
<version.org.wildfly.core>24.0.0.Beta1</version.org.wildfly.core>
<version.org.jboss.logging.slf4j-jboss-logging>1.2.1.Final</version.org.jboss.logging.slf4j-jboss-logging>
Expand Down Expand Up @@ -57,7 +57,7 @@
<galleon.fork.embedded>true</galleon.fork.embedded>

<!-- Test dependency versions -->
<version.org.wildfly.galleon-plugins>7.0.0.Beta3</version.org.wildfly.galleon-plugins>
<version.org.wildfly.galleon-plugins>7.0.0.Beta5</version.org.wildfly.galleon-plugins>
<version.jakarta.annotation.jakarta-annotation-api>2.1.1</version.jakarta.annotation.jakarta-annotation-api>
<version.jakarta.ejb.jakarta-ejb-api>4.0.1</version.jakarta.ejb.jakarta-ejb-api>
<version.jakarta.enterprise.cdi-api>4.0.1</version.jakarta.enterprise.cdi-api>
Expand Down
Loading