fix: removes the warning of ignored buildtime options, unless changed (#29425)

closes: #28654

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
Steven Hawkins 2024-05-16 13:02:13 -04:00 committed by GitHub
parent 553b1ce695
commit 8151c93bc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 11 deletions

View file

@ -64,7 +64,6 @@ import org.keycloak.config.Option;
import org.keycloak.config.OptionCategory;
import org.keycloak.quarkus.runtime.cli.command.AbstractCommand;
import org.keycloak.quarkus.runtime.cli.command.Build;
import org.keycloak.quarkus.runtime.cli.command.HelpAllMixin;
import org.keycloak.quarkus.runtime.cli.command.ImportRealmMixin;
import org.keycloak.quarkus.runtime.cli.command.Main;
import org.keycloak.quarkus.runtime.cli.command.ShowConfig;
@ -349,8 +348,11 @@ public final class Picocli {
}
if (mapper.isBuildTime() && !options.includeBuildTime) {
ignoredBuildTime.add(mapper.getFrom());
continue;
String currentValue = getRawPersistedProperty(mapper.getFrom()).orElse(null);
if (!configValueStr.equals(currentValue)) {
ignoredBuildTime.add(mapper.getFrom());
continue;
}
}
if (mapper.isRunTime() && !options.includeRuntime) {
ignoredRunTime.add(mapper.getFrom());
@ -368,9 +370,11 @@ public final class Picocli {
Logger logger = Logger.getLogger(Picocli.class); // logger can't be instantiated in a class field
if (!ignoredBuildTime.isEmpty()) {
outputIgnoredProperties(ignoredBuildTime, true, logger);
logger.warn(format("The following build time non-cli options have values that differ from what is persisted - the new values will NOT be used until another build is run: %s\n",
String.join(", ", ignoredBuildTime)));
} else if (!ignoredRunTime.isEmpty()) {
outputIgnoredProperties(ignoredRunTime, false, logger);
logger.warn(format("The following run time non-cli options were found, but will be ignored during build time: %s\n",
String.join(", ", ignoredRunTime)));
}
if (!disabledBuildTime.isEmpty()) {
@ -450,12 +454,6 @@ public final class Picocli {
disabledInUse.add(sb.toString());
}
private static void outputIgnoredProperties(List<String> properties, boolean build, Logger logger) {
logger.warn(format("The following %s time non-cli options were found, but will be ignored during %s time: %s\n",
build ? "build" : "run", build ? "run" : "build",
String.join(", ", properties)));
}
private static void outputDisabledProperties(Set<String> properties, boolean build, Logger logger) {
logger.warn(format("The following used %s time options are UNAVAILABLE and will be ignored during %s time:\n %s",
build ? "build" : "run", build ? "run" : "build",

View file

@ -158,6 +158,16 @@ public class StartCommandDistTest {
cliResult.assertNoMessage("The previous optimized build will be overridden with the following build options:"); // no message, same values provided during auto-build
}
@Test
@RawDistOnly(reason = "Containers are immutable")
void testWarningWhenOverridingNonCliBuildOptionsDuringStart(KeycloakDistribution dist) {
CLIResult cliResult = dist.run("build", "--features=preview");
cliResult.assertBuild();
dist.setEnvVar("KC_DB", "postgres");
cliResult = dist.run("start", "--optimized", "--hostname=localhost", "--http-enabled=true");
cliResult.assertMessage("The following build time non-cli options have values that differ from what is persisted - the new values will NOT be used until another build is run: kc.db");
}
@Test
@Launch({CONFIG_FILE_LONG_NAME + "=src/test/resources/non-existing.conf", "start"})
void testInvalidConfigFileOption(LaunchResult result) {