8000 Ability to set SupportLevel for categories and show marker in CLI by DGuhr · Pull Request #12917 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Closed
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
@@ -0,0 +1,8 @@
package org.keycloak.config;

public enum ConfigSupportLevel {
DEPRECATED,
EXPERIMENTAL,
PREVIEW,
SUPPORTED
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public OptionCategory getCategory() {
return category;
}

public String getDescription() { return description; }
public String getDescription() { return getDescriptionByCategorySupportLevel(description); }

public Optional<T> getDefaultValue() {
return defaultValue;
Expand All @@ -67,4 +67,20 @@ public Option<T> withRuntimeSpecificDefault(T defaultValue) {
);
}

private String getDescriptionByCategorySupportLevel(String description) {
String result;

switch(this.getCategory().getSupportLevel()) {
case PREVIEW:
result = "Preview: " + this.getDescription();
break;
case EXPERIMENTAL:
result = "Experimental: " + this.getDescription();
break;
default:
result = this.getDescription();
}

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,41 @@

public enum OptionCategory {
// ordered by name asc
CLUSTERING("Cluster", 10),
STORAGE("Storage", 15),
DATABASE("Database", 20),
TRANSACTION("Transaction",30),
FEATURE("Feature", 40),
HOSTNAME("Hostname", 50),
HTTP("HTTP/TLS", 60),
HEALTH("Health", 70),
METRICS("Metrics", 80),
PROXY("Proxy", 90),
VAULT("Vault", 100),
LOGGING("Logging", 110),
GENERAL("General", 999);

private final String heading;
CLUSTERING("Cluster", 10, ConfigSupportLevel.SUPPORTED),
STORAGE("Storage", 15, ConfigSupportLevel.EXPERIMENTAL),
DATABASE("Database", 20, ConfigSupportLevel.SUPPORTED),
TRANSACTION("Transaction",30, ConfigSupportLevel.SUPPORTED),
FEATURE("Feature", 40, ConfigSupportLevel.SUPPORTED),
HOSTNAME("Hostname", 50, ConfigSupportLevel.SUPPORTED),
HTTP("HTTP/TLS", 60, ConfigSupportLevel.SUPPORTED),
HEALTH("Health", 70, ConfigSupportLevel.SUPPORTED),
METRICS("Metrics", 80, ConfigSupportLevel.SUPPORTED),
PROXY("Proxy", 90, ConfigSupportLevel.SUPPORTED),
VAULT("Vault", 100, ConfigSupportLevel.SUPPORTED),
LOGGING("Logging", 110, ConfigSupportLevel.SUPPORTED),
GENERAL("General", 999, ConfigSupportLevel.SUPPORTED);

private String heading;
//Categories with a lower number are shown before groups with a higher number
private final int order;
private final ConfigSupportLevel supportLevel;

OptionCategory(String heading, int order) {
this.heading = heading; this.order = order;
OptionCategory(String heading, int order, ConfigSupportLevel supportLevel) {
this.order = order;
this.supportLevel = supportLevel;
this.heading = getHeadingBySupportLevel(heading);
}

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;
}

public String getHeading() {
Expand All @@ -33,4 +47,8 @@ public int getOrder() {
return this.order;
}

public ConfigSupportLevel getSupportLevel() {
return this.supportLevel;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.stream.Collectors;

import org.eclipse.microprofile.config.spi.ConfigSource;
import org.keycloak.config.ConfigSupportLevel;
import org.keycloak.config.MultiOption;
import org.keycloak.config.OptionCategory;
import org.keycloak.quarkus.runtime.cli.command.Build;
Expand Down Expand Up @@ -399,13 +400,16 @@ private static void addMappedOptionsToArgGroups(CommandSpec cSpec, List<Property

for(PropertyMapper mapper: mappersInCategory) {
String name = mapper.getCliFormat();

String description = mapper.getDescription();

if (description == null || cSpec.optionsMap().containsKey(name) || name.endsWith(OPTION_PART_SEPARATOR)) {
//when key is already added or has no description, don't add.
continue;
}

description = getDescriptionByCategorySupportLevel(category, mapper);

Iterable<String> expectedValues = mapper.getExpectedValues();

OptionSpec.Builder optBuilder = OptionSpec.builder(name)
Expand Down Expand Up @@ -439,6 +443,23 @@ private static void addMappedOptionsToArgGroups(CommandSpec cSpec, List<Property
}
}

private static String getDescriptionByCategorySupportLevel(OptionCategory category, PropertyMapper<?> mapper) {
String result;

switch(category.getSupportLevel()) {
case PREVIEW:
result = "Preview: " + mapper.getDescription();
break;
case EXPERIMENTAL:
result = &q 10BC8 uot;Experimental: " + mapper.getDescription();
break;
default:
result = mapper.getDescription();
}

return result;
}

public static void println(CommandLine cmd, String message) {
cmd.getOut().println(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ Cluster:
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.

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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ Cluster:
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.

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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ Cluster:
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.

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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ Cluster:
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.

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:

Expand Down
0