Remove deprecated auto-build CLI option (#23361)

Closes #23360
This commit is contained in:
Martin Bartoš 2023-09-27 18:56:38 +02:00 committed by GitHub
parent 69466777c0
commit c9d93019c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 17 additions and 89 deletions

View file

@ -78,3 +78,11 @@ New code example:
When running on OpenShift, with ingress enabled, and with the spec.ingress.classname set to openshift-default, you may leave the spec.hostname.hostname unpopulated in the Keycloak CR. When running on OpenShift, with ingress enabled, and with the spec.ingress.classname set to openshift-default, you may leave the spec.hostname.hostname unpopulated in the Keycloak CR.
The operator will assign a default hostname to the stored version of the CR similar to what would be created by an OpenShift Route without an explicit host - that is ingress-namespace.appsDomain The operator will assign a default hostname to the stored version of the CR similar to what would be created by an OpenShift Route without an explicit host - that is ingress-namespace.appsDomain
If the appsDomain changes, or should you need a different hostname for any reason, then update the Keycloak CR. If the appsDomain changes, or should you need a different hostname for any reason, then update the Keycloak CR.
= The deprecated `auto-build` CLI option was removed
The `auto-build` CLI option has been marked as deprecated for a long time.
In this release, it was completely removed, and it is no longer supported.
When executing the `start` command, the server is automatically built based on the configuration.
In order to prevent this behavior, set the `--optimized` flag.

View file

@ -23,12 +23,11 @@ import static org.keycloak.quarkus.runtime.Environment.getProfileOrDefault;
import static org.keycloak.quarkus.runtime.Environment.isImportExportMode; import static org.keycloak.quarkus.runtime.Environment.isImportExportMode;
import static org.keycloak.quarkus.runtime.Environment.isTestLaunchMode; import static org.keycloak.quarkus.runtime.Environment.isTestLaunchMode;
import static org.keycloak.quarkus.runtime.cli.Picocli.parseAndRun; import static org.keycloak.quarkus.runtime.cli.Picocli.parseAndRun;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.*; import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTIMIZED_BUILD_OPTION_LONG;
import static org.keycloak.quarkus.runtime.cli.command.Start.isDevProfileNotAllowed; import static org.keycloak.quarkus.runtime.cli.command.Start.isDevProfileNotAllowed;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.context.ApplicationScoped;
@ -74,7 +73,7 @@ public class KeycloakMain implements QuarkusApplication {
ExecutionExceptionHandler errorHandler = new ExecutionExceptionHandler(); ExecutionExceptionHandler errorHandler = new ExecutionExceptionHandler();
PrintWriter errStream = new PrintWriter(System.err, true); PrintWriter errStream = new PrintWriter(System.err, true);
if (isDevProfileNotAllowed(Arrays.asList(args))) { if (isDevProfileNotAllowed()) {
errorHandler.error(errStream, Messages.devProfileNotAllowedError(Start.NAME), null); errorHandler.error(errStream, Messages.devProfileNotAllowedError(Start.NAME), null);
return; return;
} }

View file

@ -21,8 +21,6 @@ import static java.util.Optional.ofNullable;
import static java.util.stream.StreamSupport.stream; import static java.util.stream.StreamSupport.stream;
import static org.keycloak.quarkus.runtime.Environment.isRebuildCheck; import static org.keycloak.quarkus.runtime.Environment.isRebuildCheck;
import static org.keycloak.quarkus.runtime.Environment.isRebuilt; import static org.keycloak.quarkus.runtime.Environment.isRebuilt;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.*;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.AUTO_BUILD_OPTION_LONG;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTIMIZED_BUILD_OPTION_LONG; import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTIMIZED_BUILD_OPTION_LONG;
import static org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource.parseConfigArgs; import static org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource.parseConfigArgs;
import static org.keycloak.quarkus.runtime.configuration.Configuration.OPTION_PART_SEPARATOR; import static org.keycloak.quarkus.runtime.configuration.Configuration.OPTION_PART_SEPARATOR;
@ -57,7 +55,6 @@ import org.eclipse.microprofile.config.spi.ConfigSource;
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.AbstractCommand; import org.keycloak.quarkus.runtime.cli.command.AbstractCommand;
import org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand;
import org.keycloak.quarkus.runtime.cli.command.Build; import org.keycloak.quarkus.runtime.cli.command.Build;
import org.keycloak.quarkus.runtime.cli.command.ImportRealmMixin; import org.keycloak.quarkus.runtime.cli.command.ImportRealmMixin;
import org.keycloak.quarkus.runtime.cli.command.Main; import org.keycloak.quarkus.runtime.cli.command.Main;
@ -527,10 +524,6 @@ public final class Picocli {
} }
} }
} }
if (!isRebuildCheck() && (arg.startsWith(AbstractStartCommand.AUTO_BUILD_OPTION_SHORT) || arg.startsWith(AUTO_BUILD_OPTION_LONG))) {
System.out.println(DEFAULT_WARN_MESSAGE_REPEATED_AUTO_BUILD_OPTION);
}
} }
return args; return args;
@ -544,11 +537,6 @@ public final class Picocli {
} }
private static boolean isRuntimeOption(String arg) { private static boolean isRuntimeOption(String arg) {
// remove this once auto-build option is removed
if (AUTO_BUILD_OPTION_LONG.equals(arg) || AUTO_BUILD_OPTION_SHORT.equals(arg)) {
return true;
}
return arg.startsWith(ImportRealmMixin.IMPORT_REALM); return arg.startsWith(ImportRealmMixin.IMPORT_REALM);
} }

View file

@ -23,12 +23,7 @@ import org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler;
import picocli.CommandLine; import picocli.CommandLine;
public abstract class AbstractStartCommand extends AbstractCommand implements Runnable { public abstract class AbstractStartCommand extends AbstractCommand implements Runnable {
// remove this once auto-build is removed
public static final String AUTO_BUILD_OPTION_LONG = "--auto-build";
public static final String AUTO_BUILD_OPTION_SHORT = "-b";
public static final String OPTIMIZED_BUILD_OPTION_LONG = "--optimized"; public static final String OPTIMIZED_BUILD_OPTION_LONG = "--optimized";
public static final String DEFAULT_WARN_MESSAGE_REPEATED_AUTO_BUILD_OPTION = "WARNING: The '" + AUTO_BUILD_OPTION_LONG + "' option for 'start' command is DEPRECATED and no longer needed. When executing the '" + Start.NAME + "' command, a new server image is automatically built based on the configuration. If you want to disable this behavior and achieve an optimal startup time, use the '" + OPTIMIZED_BUILD_OPTION_LONG + "' option instead.";
@Override @Override
public void run() { public void run() {

View file

@ -18,7 +18,6 @@
package org.keycloak.quarkus.runtime.cli.command; package org.keycloak.quarkus.runtime.cli.command;
import static org.keycloak.quarkus.runtime.Environment.setProfile; import static org.keycloak.quarkus.runtime.Environment.setProfile;
import static org.keycloak.quarkus.runtime.cli.Picocli.NO_PARAM_LABEL;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTIMIZED_BUILD_OPTION_LONG; import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTIMIZED_BUILD_OPTION_LONG;
import static org.keycloak.quarkus.runtime.configuration.Configuration.getRawPersistedProperty; import static org.keycloak.quarkus.runtime.configuration.Configuration.getRawPersistedProperty;
@ -45,14 +44,6 @@ public final class Start extends AbstractStartCommand implements Runnable {
public static final String NAME = "start"; public static final String NAME = "start";
@CommandLine.Option(names = {AUTO_BUILD_OPTION_SHORT, AUTO_BUILD_OPTION_LONG},
description = "(Deprecated) Automatically detects whether the server configuration changed and a new server image must be built" +
" prior to starting the server. This option provides an alternative to manually running the '" + Build.NAME + "'" +
" prior to starting the server. Use this configuration carefully in production as it might impact the startup time.",
paramLabel = NO_PARAM_LABEL,
order = 1)
Boolean autoConfig;
@CommandLine.Mixin @CommandLine.Mixin
OptimizedMixin optimizedMixin; OptimizedMixin optimizedMixin;
@ -68,22 +59,18 @@ public final class Start extends AbstractStartCommand implements Runnable {
} }
private void devProfileNotAllowedError() { private void devProfileNotAllowedError() {
if (isDevProfileNotAllowed(spec.commandLine().getParseResult().expandedArgs())) { if (isDevProfileNotAllowed()) {
executionError(spec.commandLine(), Messages.devProfileNotAllowedError(NAME)); executionError(spec.commandLine(), Messages.devProfileNotAllowedError(NAME));
} }
} }
public static boolean isDevProfileNotAllowed(List<String> currentCliArgs) { public static boolean isDevProfileNotAllowed() {
Optional<String> currentProfile = Optional.ofNullable(Environment.getProfile()); Optional<String> currentProfile = Optional.ofNullable(Environment.getProfile());
Optional<String> persistedProfile = getRawPersistedProperty("kc.profile"); Optional<String> persistedProfile = getRawPersistedProperty("kc.profile");
setProfile(currentProfile.orElse(persistedProfile.orElse("prod"))); setProfile(currentProfile.orElse(persistedProfile.orElse("prod")));
if (Environment.isDevProfile() && (!currentCliArgs.contains(AUTO_BUILD_OPTION_LONG) || !currentCliArgs.contains(AUTO_BUILD_OPTION_SHORT))) { return Environment.isDevProfile();
return true;
}
return false;
} }
public List<OptionCategory> getOptionCategories() { public List<OptionCategory> getOptionCategories() {

View file

@ -23,7 +23,6 @@ import org.keycloak.quarkus.runtime.Environment;
import picocli.CommandLine; import picocli.CommandLine;
import picocli.CommandLine.Command; import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin; import picocli.CommandLine.Mixin;
import picocli.CommandLine.Option;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -39,9 +38,6 @@ public final class StartDev extends AbstractStartCommand implements Runnable {
public static final String NAME = "start-dev"; public static final String NAME = "start-dev";
@Option(names = AUTO_BUILD_OPTION_LONG, hidden = true)
Boolean autoConfig;
@Mixin @Mixin
HelpAllMixin helpAllMixin; HelpAllMixin helpAllMixin;

View file

@ -19,8 +19,6 @@ package org.keycloak.quarkus.runtime.configuration;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.keycloak.quarkus.runtime.cli.Picocli.ARG_SHORT_PREFIX; import static org.keycloak.quarkus.runtime.cli.Picocli.ARG_SHORT_PREFIX;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.AUTO_BUILD_OPTION_LONG;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.AUTO_BUILD_OPTION_SHORT;
import static org.keycloak.quarkus.runtime.configuration.Configuration.OPTION_PART_SEPARATOR_CHAR; import static org.keycloak.quarkus.runtime.configuration.Configuration.OPTION_PART_SEPARATOR_CHAR;
import static org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider.NS_KEYCLOAK_PREFIX; import static org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider.NS_KEYCLOAK_PREFIX;
@ -35,6 +33,7 @@ import io.smallrye.config.PropertiesConfigSource;
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper; import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper;
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers; import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers;
import org.keycloak.utils.StringUtil;
/** /**
* <p>A configuration source for mapping configuration arguments to their corresponding properties so that they can be recognized * <p>A configuration source for mapping configuration arguments to their corresponding properties so that they can be recognized
@ -134,10 +133,10 @@ public class ConfigArgsConfigSource extends PropertiesConfigSource {
public static void parseConfigArgs(BiConsumer<String, String> cliArgConsumer) { public static void parseConfigArgs(BiConsumer<String, String> cliArgConsumer) {
// init here because the class might be loaded by CL without init // init here because the class might be loaded by CL without init
List<String> ignoredArgs = asList("--verbose", "-v", "--help", "-h", AUTO_BUILD_OPTION_LONG, AUTO_BUILD_OPTION_SHORT); List<String> ignoredArgs = asList("--verbose", "-v", "--help", "-h");
String rawArgs = getRawConfigArgs(); String rawArgs = getRawConfigArgs();
if (rawArgs == null || "".equals(rawArgs.trim())) { if (StringUtil.isBlank(rawArgs)) {
return; return;
} }

View file

@ -27,11 +27,9 @@ import org.keycloak.it.junit5.extension.CLIResult;
import org.keycloak.it.junit5.extension.DistributionTest; import org.keycloak.it.junit5.extension.DistributionTest;
import org.keycloak.it.junit5.extension.RawDistOnly; import org.keycloak.it.junit5.extension.RawDistOnly;
import org.keycloak.it.utils.KeycloakDistribution; import org.keycloak.it.utils.KeycloakDistribution;
import org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.DEFAULT_WARN_MESSAGE_REPEATED_AUTO_BUILD_OPTION;
import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTIMIZED_BUILD_OPTION_LONG; import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTIMIZED_BUILD_OPTION_LONG;
@DistributionTest @DistributionTest
@ -40,7 +38,7 @@ import static org.keycloak.quarkus.runtime.cli.command.AbstractStartCommand.OPTI
public class StartAutoBuildDistTest { public class StartAutoBuildDistTest {
@Test @Test
@Launch({ "start", AbstractStartCommand.AUTO_BUILD_OPTION_LONG, "--http-enabled=true", "--hostname-strict=false" }) @Launch({ "start", "--http-enabled=true", "--hostname-strict=false" })
@Order(1) @Order(1)
void testStartAutoBuild(LaunchResult result) { void testStartAutoBuild(LaunchResult result) {
CLIResult cliResult = (CLIResult) result; CLIResult cliResult = (CLIResult) result;
@ -50,7 +48,6 @@ public class StartAutoBuildDistTest {
cliResult.assertMessage(KeycloakDistribution.SCRIPT_CMD + " show-config"); cliResult.assertMessage(KeycloakDistribution.SCRIPT_CMD + " show-config");
cliResult.assertMessage("Next time you run the server, just run:"); cliResult.assertMessage("Next time you run the server, just run:");
cliResult.assertMessage(KeycloakDistribution.SCRIPT_CMD + " start " + OPTIMIZED_BUILD_OPTION_LONG + " --http-enabled=true --hostname-strict=false"); cliResult.assertMessage(KeycloakDistribution.SCRIPT_CMD + " start " + OPTIMIZED_BUILD_OPTION_LONG + " --http-enabled=true --hostname-strict=false");
cliResult.assertMessage(DEFAULT_WARN_MESSAGE_REPEATED_AUTO_BUILD_OPTION);
assertFalse(cliResult.getOutput().contains("--cache")); assertFalse(cliResult.getOutput().contains("--cache"));
cliResult.assertStarted(); cliResult.assertStarted();
} }
@ -104,7 +101,6 @@ public class StartAutoBuildDistTest {
@Order(7) @Order(7)
void testShouldReAugWithoutAutoBuildOptionAfterDatabaseChange(LaunchResult result) { void testShouldReAugWithoutAutoBuildOptionAfterDatabaseChange(LaunchResult result) {
CLIResult cliResult = (CLIResult) result; CLIResult cliResult = (CLIResult) result;
cliResult.assertNoMessage(DEFAULT_WARN_MESSAGE_REPEATED_AUTO_BUILD_OPTION);
cliResult.assertBuild(); cliResult.assertBuild();
} }

View file

@ -8,11 +8,6 @@ Use this command to run the server in production.
Options: Options:
-b, --auto-build (Deprecated) Automatically detects whether the server configuration changed
and a new server image must be built prior to starting the server. This
option provides an alternative to manually running the 'build' prior to
starting the server. Use this configuration carefully in production as it
might impact the startup time.
-h, --help This help message. -h, --help This help message.
--help-all This same help message but with additional options. --help-all This same help message but with additional options.
--import-realm Import realms during startup by reading any realm configuration file from the --import-realm Import realms during startup by reading any realm configuration file from the

View file

@ -8,11 +8,6 @@ Use this command to run the server in production.
Options: Options:
-b, --auto-build (Deprecated) Automatically detects whether the server configuration changed
and a new server image must be built prior to starting the server. This
option provides an alternative to manually running the 'build' prior to
starting the server. Use this configuration carefully in production as it
might impact the startup time.
-h, --help This help message. -h, --help This help message.
--help-all This same help message but with additional options. --help-all This same help message but with additional options.
--import-realm Import realms during startup by reading any realm configuration file from the --import-realm Import realms during startup by reading any realm configuration file from the

View file

@ -8,11 +8,6 @@ Use this command to run the server in production.
Options: Options:
-b, --auto-build (Deprecated) Automatically detects whether the server configuration changed
and a new server image must be built prior to starting the server. This
option provides an alternative to manually running the 'build' prior to
starting the server. Use this configuration carefully in production as it
might impact the startup time.
-h, --help This help message. -h, --help This help message.
--help-all This same help message but with additional options. --help-all This same help message but with additional options.
--import-realm Import realms during startup by reading any realm configuration file from the --import-realm Import realms during startup by reading any realm configuration file from the

View file

@ -8,11 +8,6 @@ Use this command to run the server in production.
Options: Options:
-b, --auto-build (Deprecated) Automatically detects whether the server configuration changed
and a new server image must be built prior to starting the server. This
option provides an alternative to manually running the 'build' prior to
starting the server. Use this configuration carefully in production as it
might impact the startup time.
-h, --help This help message. -h, --help This help message.
--help-all This same help message but with additional options. --help-all This same help message but with additional options.
--import-realm Import realms during startup by reading any realm configuration file from the --import-realm Import realms during startup by reading any realm configuration file from the

View file

@ -8,11 +8,6 @@ Use this command to run the server in production.
Options: Options:
-b, --auto-build (Deprecated) Automatically detects whether the server configuration changed
and a new server image must be built prior to starting the server. This
option provides an alternative to manually running the 'build' prior to
starting the server. Use this configuration carefully in production as it
might impact the startup time.
-h, --help This help message. -h, --help This help message.
--help-all This same help message but with additional options. --help-all This same help message but with additional options.
--import-realm Import realms during startup by reading any realm configuration file from the --import-realm Import realms during startup by reading any realm configuration file from the

View file

@ -8,11 +8,6 @@ Use this command to run the server in production.
Options: Options:
-b, --auto-build (Deprecated) Automatically detects whether the server configuration changed
and a new server image must be built prior to starting the server. This
option provides an alternative to manually running the 'build' prior to
starting the server. Use this configuration carefully in production as it
might impact the startup time.
-h, --help This help message. -h, --help This help message.
--help-all This same help message but with additional options. --help-all This same help message but with additional options.
--import-realm Import realms during startup by reading any realm configuration file from the --import-realm Import realms during startup by reading any realm configuration file from the

View file

@ -8,11 +8,6 @@ Use this command to run the server in production.
Options: Options:
-b, --auto-build (Deprecated) Automatically detects whether the server configuration changed
and a new server image must be built prior to starting the server. This
option provides an alternative to manually running the 'build' prior to
starting the server. Use this configuration carefully in production as it
might impact the startup time.
-h, --help This help message. -h, --help This help message.
--help-all This same help message but with additional options. --help-all This same help message but with additional options.
--import-realm Import realms during startup by reading any realm configuration file from the --import-realm Import realms during startup by reading any realm configuration file from the

View file

@ -8,11 +8,6 @@ Use this command to run the server in production.
Options: Options:
-b, --auto-build (Deprecated) Automatically detects whether the server configuration changed
and a new server image must be built prior to starting the server. This
option provides an alternative to manually running the 'build' prior to
starting the server. Use this configuration carefully in production as it
might impact the startup time.
-h, --help This help message. -h, --help This help message.
--help-all This same help message but with additional options. --help-all This same help message but with additional options.
--import-realm Import realms during startup by reading any realm configuration file from the --import-realm Import realms during startup by reading any realm configuration file from the