mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-07 23:39:50 -06:00
Restore KeycloakServerConfigBuilder to use single --features and --features-disabled arguments (#44322)
Signed-off-by: stianst <stianst@gmail.com>
This commit is contained in:
@@ -27,8 +27,8 @@ public class KeycloakServerConfigBuilder {
|
||||
|
||||
private final String command;
|
||||
private final Map<String, String> options = new HashMap<>();
|
||||
private final Set<Profile.Feature> features = new HashSet<>();
|
||||
private final Set<Profile.Feature> featuresDisabled = new HashSet<>();
|
||||
private final Set<String> features = new HashSet<>();
|
||||
private final Set<String> featuresDisabled = new HashSet<>();
|
||||
private final LogBuilder log = new LogBuilder();
|
||||
private final Set<Dependency> dependencies = new HashSet<>();
|
||||
private final Set<Path> configFiles = new HashSet<>();
|
||||
@@ -79,12 +79,12 @@ public class KeycloakServerConfigBuilder {
|
||||
}
|
||||
|
||||
public KeycloakServerConfigBuilder features(Profile.Feature... features) {
|
||||
this.features.addAll(List.of(features));
|
||||
this.features.addAll(toFeatureStrings(features));
|
||||
return this;
|
||||
}
|
||||
|
||||
public KeycloakServerConfigBuilder featuresDisabled(Profile.Feature... features) {
|
||||
this.featuresDisabled.addAll(List.of(features));
|
||||
this.featuresDisabled.addAll(toFeatureStrings(features));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -231,9 +231,12 @@ public class KeycloakServerConfigBuilder {
|
||||
for (Map.Entry<String, String> e : options.entrySet()) {
|
||||
args.add("--" + e.getKey() + "=" + e.getValue());
|
||||
}
|
||||
|
||||
features.forEach(f -> args.add("--feature-%s=v%s".formatted(f.getUnversionedKey(), f.getVersion())));
|
||||
featuresDisabled.forEach(f -> args.add("--feature-%s=disabled".formatted(f.getUnversionedKey())));
|
||||
if (!features.isEmpty()) {
|
||||
args.add("--features=" + String.join(",", features));
|
||||
}
|
||||
if (!featuresDisabled.isEmpty()) {
|
||||
args.add("--features-disabled=" + String.join(",", featuresDisabled));
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
@@ -246,6 +249,15 @@ public class KeycloakServerConfigBuilder {
|
||||
return configFiles;
|
||||
}
|
||||
|
||||
private Set<String> toFeatureStrings(Profile.Feature... features) {
|
||||
return Arrays.stream(features).map(f -> {
|
||||
if (f.getVersion() > 1 || Profile.getFeatureVersions(f.getKey()).size() > 1) {
|
||||
return f.getVersionedKey();
|
||||
}
|
||||
return f.getUnversionedKey();
|
||||
}).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public enum LogHandlers {
|
||||
CONSOLE,
|
||||
FILE,
|
||||
|
||||
Reference in New Issue
Block a user