Baseline: Ability to set SupportLevel for categories and show marker in CLI help

Closes #12927
This commit is contained in:
Dominik Guhr 2022-07-05 09:57:28 +02:00 committed by Bruno Oliveira da Silva
parent 29a501552e
commit 1edce54aff
8 changed files with 75 additions and 27 deletions

View file

@ -0,0 +1,8 @@
package org.keycloak.config;
public enum ConfigSupportLevel {
DEPRECATED,
EXPERIMENTAL,
PREVIEW,
SUPPORTED
}

View file

@ -2,7 +2,6 @@ package org.keycloak.config;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
public class Option<T> { public class Option<T> {
@ -21,7 +20,7 @@ public class Option<T> {
this.category = category; this.category = category;
this.hidden = hidden; this.hidden = hidden;
this.buildTime = buildTime; this.buildTime = buildTime;
this.description = description; this.description = getDescriptionByCategorySupportLevel(description);
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
this.expectedValues = expectedValues; this.expectedValues = expectedValues;
} }
@ -67,4 +66,22 @@ public class Option<T> {
); );
} }
private String getDescriptionByCategorySupportLevel(String description) {
if(description == null || description.isBlank()) {
return description;
}
switch(this.getCategory().getSupportLevel()) {
case PREVIEW:
description = "Preview: " + description;
break;
case EXPERIMENTAL:
description = "Experimental: " + description;
break;
default:
description = description;
}
return description;
}
} }

View file

@ -2,27 +2,29 @@ package org.keycloak.config;
public enum OptionCategory { public enum OptionCategory {
// ordered by name asc // ordered by name asc
CLUSTERING("Cluster", 10), CLUSTERING("Cluster", 10, ConfigSupportLevel.SUPPORTED),
STORAGE("Storage", 15), STORAGE("Storage", 15, ConfigSupportLevel.EXPERIMENTAL),
DATABASE("Database", 20), DATABASE("Database", 20, ConfigSupportLevel.SUPPORTED),
TRANSACTION("Transaction",30), TRANSACTION("Transaction",30, ConfigSupportLevel.SUPPORTED),
FEATURE("Feature", 40), FEATURE("Feature", 40, ConfigSupportLevel.SUPPORTED),
HOSTNAME("Hostname", 50), HOSTNAME("Hostname", 50, ConfigSupportLevel.SUPPORTED),
HTTP("HTTP/TLS", 60), HTTP("HTTP/TLS", 60, ConfigSupportLevel.SUPPORTED),
HEALTH("Health", 70), HEALTH("Health", 70, ConfigSupportLevel.SUPPORTED),
METRICS("Metrics", 80), METRICS("Metrics", 80, ConfigSupportLevel.SUPPORTED),
PROXY("Proxy", 90), PROXY("Proxy", 90, ConfigSupportLevel.SUPPORTED),
VAULT("Vault", 100), VAULT("Vault", 100, ConfigSupportLevel.SUPPORTED),
LOGGING("Logging", 110), LOGGING("Logging", 110, ConfigSupportLevel.SUPPORTED),
GENERAL("General", 999); GENERAL("General", 999, ConfigSupportLevel.SUPPORTED);
private final String heading;
private String heading;
//Categories with a lower number are shown before groups with a higher number //Categories with a lower number are shown before groups with a higher number
private final int order; private final int order;
private final ConfigSupportLevel supportLevel;
OptionCategory(String heading, int order) { OptionCategory(String heading, int order, ConfigSupportLevel supportLevel) {
this.heading = heading; this.order = order; this.order = order;
this.supportLevel = supportLevel;
this.heading = getHeadingBySupportLevel(heading);
} }
public String getHeading() { public String getHeading() {
@ -33,4 +35,19 @@ public enum OptionCategory {
return this.order; return this.order;
} }
public ConfigSupportLevel getSupportLevel() {
return this.supportLevel;
}
private String getHeadingBySupportLevel(String heading) {
if (this.supportLevel.equals(ConfigSupportLevel.EXPERIMENTAL)){
heading = heading + " (Experimental)";
}
if (this.supportLevel.equals(ConfigSupportLevel.PREVIEW)){
heading = heading + " (Preview)";
}
return heading;
}
} }

View file

@ -47,6 +47,7 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.microprofile.config.spi.ConfigSource; import org.eclipse.microprofile.config.spi.ConfigSource;
import org.keycloak.config.ConfigSupportLevel;
import org.keycloak.config.MultiOption; import org.keycloak.config.MultiOption;
import org.keycloak.config.OptionCategory; import org.keycloak.config.OptionCategory;
import org.keycloak.quarkus.runtime.cli.command.Build; import org.keycloak.quarkus.runtime.cli.command.Build;
@ -399,6 +400,7 @@ public final class Picocli {
for(PropertyMapper mapper: mappersInCategory) { for(PropertyMapper mapper: mappersInCategory) {
String name = mapper.getCliFormat(); String name = mapper.getCliFormat();
String description = mapper.getDescription(); String description = mapper.getDescription();
if (description == null || cSpec.optionsMap().containsKey(name) || name.endsWith(OPTION_PART_SEPARATOR)) { if (description == null || cSpec.optionsMap().containsKey(name) || name.endsWith(OPTION_PART_SEPARATOR)) {

View file

@ -35,9 +35,10 @@ Cluster:
Define the default stack to use for cluster communication and node discovery. Define the default stack to use for cluster communication and node discovery.
This option only takes effect if 'cache' is set to 'ispn'. Default: udp. This option only takes effect if 'cache' is set to 'ispn'. Default: udp.
Storage: Storage (Experimental):
--storage <type> Sets a storage mechanism. Possible values are: legacy, chm. Default: legacy. --storage <type> Experimental: Sets a storage mechanism. Possible values are: legacy, chm.
Default: legacy.
Database: Database:

View file

@ -35,9 +35,10 @@ Cluster:
Define the default stack to use for cluster communication and node discovery. Define the default stack to use for cluster communication and node discovery.
This option only takes effect if 'cache' is set to 'ispn'. Default: udp. This option only takes effect if 'cache' is set to 'ispn'. Default: udp.
Storage: Storage (Experimental):
--storage <type> Sets a storage mechanism. Possible values are: legacy, chm. Default: legacy. --storage <type> Experimental: Sets a storage mechanism. Possible values are: legacy, chm. Default:
legacy.
Database: Database:

View file

@ -27,9 +27,10 @@ Cluster:
Define the default stack to use for cluster communication and node discovery. Define the default stack to use for cluster communication and node discovery.
This option only takes effect if 'cache' is set to 'ispn'. Default: udp. This option only takes effect if 'cache' is set to 'ispn'. Default: udp.
Storage: Storage (Experimental):
--storage <type> Sets a storage mechanism. Possible values are: legacy, chm. Default: legacy. --storage <type> Experimental: Sets a storage mechanism. Possible values are: legacy, chm.
Default: legacy.
Database: Database:

View file

@ -27,9 +27,10 @@ Cluster:
Define the default stack to use for cluster communication and node discovery. Define the default stack to use for cluster communication and node discovery.
This option only takes effect if 'cache' is set to 'ispn'. Default: udp. This option only takes effect if 'cache' is set to 'ispn'. Default: udp.
Storage: Storage (Experimental):
--storage <type> Sets a storage mechanism. Possible values are: legacy, chm. Default: legacy. --storage <type> Experimental: Sets a storage mechanism. Possible values are: legacy, chm. Default:
legacy.
Database: Database: