Skip to content

Commit

Permalink
Merge pull request quarkusio#28111 from gsmet/2.13.0-backports-2
Browse files Browse the repository at this point in the history
2.13.0 backports 2
  • Loading branch information
gsmet authored Sep 21, 2022
2 parents 73f5a5f + aa1c56a commit a94e22a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization;
import org.graalvm.nativeimage.hosted.RuntimeReflection;
import org.graalvm.nativeimage.impl.ConfigurationCondition;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand Down Expand Up @@ -76,14 +75,15 @@ public class NativeImageFeatureStep {
"org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport",
"rerunInitialization", void.class, Class.class, String.class);

public static final String CONFIGURATION_CONDITION = "org.graalvm.nativeimage.impl.ConfigurationCondition";
private static final MethodDescriptor CONFIGURATION_ALWAYS_TRUE = ofMethod(
"org.graalvm.nativeimage.impl.ConfigurationCondition",
"alwaysTrue", "org.graalvm.nativeimage.impl.ConfigurationCondition");
CONFIGURATION_CONDITION,
"alwaysTrue", CONFIGURATION_CONDITION);

private static final MethodDescriptor REGISTER_LAMBDA_CAPTURING_CLASS = ofMethod(
"org.graalvm.nativeimage.impl.RuntimeSerializationSupport",
"registerLambdaCapturingClass", void.class,
"org.graalvm.nativeimage.impl.ConfigurationCondition",
CONFIGURATION_CONDITION,
String.class);

private static final MethodDescriptor LOOKUP_METHOD = ofMethod(
Expand Down Expand Up @@ -311,7 +311,7 @@ public void write(String s, byte[] bytes) {

TryBlock tc = overallCatch.tryBlock();

ResultHandle resourcesArgTypes = tc.marshalAsArray(Class.class, tc.loadClassFromTCCL(ConfigurationCondition.class),
ResultHandle resourcesArgTypes = tc.marshalAsArray(Class.class, tc.loadClassFromTCCL(CONFIGURATION_CONDITION),
tc.loadClassFromTCCL(String.class));
AssignableResultHandle resourcesArgs = tc.createVariable(Object[].class);
tc.assign(resourcesArgs,
Expand Down Expand Up @@ -387,7 +387,7 @@ public void write(String s, byte[] bytes) {

ResultHandle runtimeResourceSupportClass = greaterThan22_2.loadClassFromTCCL(RUNTIME_RESOURCE_SUPPORT);
ResultHandle addResourceBundlesParams = greaterThan22_2.marshalAsArray(Class.class,
greaterThan22_2.loadClassFromTCCL(ConfigurationCondition.class),
greaterThan22_2.loadClassFromTCCL(CONFIGURATION_CONDITION),
greaterThan22_2.loadClassFromTCCL(String.class));
ResultHandle addResourceBundlesMethod = greaterThan22_2.invokeStaticMethod(
LOOKUP_METHOD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ private String getCookieToken(RoutingContext routing, CsrfReactiveConfig config)
}

private boolean isCsrfTokenRequired(RoutingContext routing, CsrfReactiveConfig config) {
LOG.error("**************Request path: " + routing.request().path());
LOG.error("**************Token path: " + config.createTokenPath.get());
return config.createTokenPath.isPresent() ? config.createTokenPath.get().equals(routing.request().path()) : true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ public class DevServicesConfig {
@ConfigItem
public Optional<String> javaOpts;

/**
* Show Keycloak log messages with a "Keycloak:" prefix.
*/
@ConfigItem(defaultValue = "false")
public boolean showLogs;

/**
* Keycloak start command.
* Use this property to experiment with Keycloak start options, see {@link https://www.keycloak.org/server/all-config}.
* Note it will be ignored when loading legacy Keycloak WildFly images.
*/
@ConfigItem
public Optional<String> startCommand;

/**
* The Keycloak realm name.
* This property will be used to create the realm if the realm file pointed to by the 'realm-path' property does not exist,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ private RunningDevService startContainer(DockerStatusBuildItem dockerStatusBuild
capturedDevServicesConfiguration.realmPath,
capturedDevServicesConfiguration.serviceName,
capturedDevServicesConfiguration.shared,
capturedDevServicesConfiguration.javaOpts);
capturedDevServicesConfiguration.javaOpts,
capturedDevServicesConfiguration.startCommand,
capturedDevServicesConfiguration.showLogs);

timeout.ifPresent(oidcContainer::withStartupTimeout);
oidcContainer.start();
Expand Down Expand Up @@ -383,10 +385,12 @@ private static class QuarkusOidcContainer extends GenericContainer<QuarkusOidcCo
private String hostName;
private final boolean keycloakX;
private RealmRepresentation realmRep;
private final Optional<String> startCommand;
private final boolean showLogs;

public QuarkusOidcContainer(DockerImageName dockerImageName, OptionalInt fixedExposedPort, boolean useSharedNetwork,
Optional<String> realmPath, String containerLabelValue,
boolean sharedContainer, Optional<String> javaOpts) {
boolean sharedContainer, Optional<String> javaOpts, Optional<String> startCommand, boolean showLogs) {
super(dockerImageName);

this.useSharedNetwork = useSharedNetwork;
Expand All @@ -404,6 +408,8 @@ public QuarkusOidcContainer(DockerImageName dockerImageName, OptionalInt fixedEx
}

this.fixedExposedPort = fixedExposedPort;
this.startCommand = startCommand;
this.showLogs = showLogs;
}

@Override
Expand Down Expand Up @@ -436,7 +442,7 @@ protected void configure() {
if (keycloakX) {
addEnv(KEYCLOAK_QUARKUS_ADMIN_PROP, KEYCLOAK_ADMIN_USER);
addEnv(KEYCLOAK_QUARKUS_ADMIN_PASSWORD_PROP, KEYCLOAK_ADMIN_PASSWORD);
withCommand(KEYCLOAK_QUARKUS_START_CMD
withCommand(startCommand.orElse(KEYCLOAK_QUARKUS_START_CMD)
+ (useSharedNetwork ? " --hostname-port=" + fixedExposedPort.getAsInt() : ""));
} else {
addEnv(KEYCLOAK_WILDFLY_USER_PROP, KEYCLOAK_ADMIN_USER);
Expand Down Expand Up @@ -469,6 +475,12 @@ protected void configure() {
addEnv(KEYCLOAK_WILDFLY_IMPORT_PROP, KEYCLOAK_DOCKER_REALM_PATH);
}

if (showLogs) {
super.withLogConsumer(t -> {
LOG.info("Keycloak: " + t.getUtf8String());
});
}

LOG.infof("Using %s powered Keycloak distribution", keycloakX ? "Quarkus" : "WildFly");
super.setWaitStrategy(Wait.forLogMessage(".*Keycloak.*started.*", 1));
}
Expand Down

0 comments on commit a94e22a

Please sign in to comment.