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:
parent
553b1ce695
commit
8151c93bc7
2 changed files with 19 additions and 11 deletions
|
@ -64,7 +64,6 @@ import org.keycloak.config.Option;
|
||||||
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.Build;
|
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.ImportRealmMixin;
|
||||||
import org.keycloak.quarkus.runtime.cli.command.Main;
|
import org.keycloak.quarkus.runtime.cli.command.Main;
|
||||||
import org.keycloak.quarkus.runtime.cli.command.ShowConfig;
|
import org.keycloak.quarkus.runtime.cli.command.ShowConfig;
|
||||||
|
@ -349,9 +348,12 @@ public final class Picocli {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapper.isBuildTime() && !options.includeBuildTime) {
|
if (mapper.isBuildTime() && !options.includeBuildTime) {
|
||||||
|
String currentValue = getRawPersistedProperty(mapper.getFrom()).orElse(null);
|
||||||
|
if (!configValueStr.equals(currentValue)) {
|
||||||
ignoredBuildTime.add(mapper.getFrom());
|
ignoredBuildTime.add(mapper.getFrom());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (mapper.isRunTime() && !options.includeRuntime) {
|
if (mapper.isRunTime() && !options.includeRuntime) {
|
||||||
ignoredRunTime.add(mapper.getFrom());
|
ignoredRunTime.add(mapper.getFrom());
|
||||||
continue;
|
continue;
|
||||||
|
@ -368,9 +370,11 @@ public final class Picocli {
|
||||||
Logger logger = Logger.getLogger(Picocli.class); // logger can't be instantiated in a class field
|
Logger logger = Logger.getLogger(Picocli.class); // logger can't be instantiated in a class field
|
||||||
|
|
||||||
if (!ignoredBuildTime.isEmpty()) {
|
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()) {
|
} 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()) {
|
if (!disabledBuildTime.isEmpty()) {
|
||||||
|
@ -450,12 +454,6 @@ public final class Picocli {
|
||||||
disabledInUse.add(sb.toString());
|
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) {
|
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",
|
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",
|
build ? "build" : "run", build ? "run" : "build",
|
||||||
|
|
|
@ -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
|
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
|
@Test
|
||||||
@Launch({CONFIG_FILE_LONG_NAME + "=src/test/resources/non-existing.conf", "start"})
|
@Launch({CONFIG_FILE_LONG_NAME + "=src/test/resources/non-existing.conf", "start"})
|
||||||
void testInvalidConfigFileOption(LaunchResult result) {
|
void testInvalidConfigFileOption(LaunchResult result) {
|
||||||
|
|
Loading…
Reference in a new issue