Skip to content

Commit

Permalink
Move http configuration to @ConfigMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Jan 21, 2025
1 parent 7d65aa3 commit 45bcf5c
Show file tree
Hide file tree
Showing 101 changed files with 1,432 additions and 1,510 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import java.util.List;
import java.util.Optional;

import org.jboss.logging.Logger;

import com.fasterxml.jackson.databind.ObjectMapper;

import io.quarkus.arc.deployment.BeanContainerBuildItem;
Expand All @@ -25,12 +23,11 @@
import io.quarkus.vertx.core.deployment.CoreVertxBuildItem;
import io.quarkus.vertx.http.deployment.RequireBodyHandlerBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig;
import io.quarkus.vertx.http.runtime.VertxHttpBuildTimeConfig;
import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;

public class FunqyHttpBuildStep {
private static final Logger log = Logger.getLogger(FunqyHttpBuildStep.class);
public static final String FUNQY_HTTP_FEATURE = "funqy-http";

@BuildStep
Expand All @@ -55,12 +52,12 @@ public RequireBodyHandlerBuildItem requestBodyHandler(List<FunctionBuildItem> fu
public void staticInit(FunqyHttpBindingRecorder binding,
BeanContainerBuildItem beanContainer, // dependency
Optional<FunctionInitializedBuildItem> hasFunctions,
HttpBuildTimeConfig httpConfig) throws Exception {
VertxHttpBuildTimeConfig httpBuildTimeConfig) throws Exception {
if (!hasFunctions.isPresent() || hasFunctions.get() == null)
return;

// The context path + the resources path
String rootPath = httpConfig.rootPath;
String rootPath = httpBuildTimeConfig.rootPath();
binding.init();
}

Expand All @@ -74,14 +71,14 @@ public void boot(ShutdownContextBuildItem shutdown,
Optional<FunctionInitializedBuildItem> hasFunctions,
List<FunctionBuildItem> functions,
BeanContainerBuildItem beanContainer,
HttpBuildTimeConfig httpConfig,
VertxHttpBuildTimeConfig httpConfig,
ExecutorBuildItem executorBuildItem) throws Exception {

if (!hasFunctions.isPresent() || hasFunctions.get() == null)
return;
feature.produce(new FeatureBuildItem(FUNQY_HTTP_FEATURE));

String rootPath = httpConfig.rootPath;
String rootPath = httpConfig.rootPath();
Handler<RoutingContext> handler = binding.start(rootPath,
vertx.getVertx(),
shutdown,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import io.quarkus.vertx.core.deployment.CoreVertxBuildItem;
import io.quarkus.vertx.http.deployment.RequireBodyHandlerBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig;
import io.quarkus.vertx.http.runtime.VertxHttpBuildTimeConfig;
import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;

Expand Down Expand Up @@ -75,14 +75,14 @@ public void boot(ShutdownContextBuildItem shutdown,
BuildProducer<RouteBuildItem> routes,
CoreVertxBuildItem vertx,
BeanContainerBuildItem beanContainer,
HttpBuildTimeConfig httpConfig,
VertxHttpBuildTimeConfig httpBuildTimeConfig,
ExecutorBuildItem executorBuildItem) throws Exception {
if (!hasFunctions.isPresent() || hasFunctions.get() == null)
return;

feature.produce(new FeatureBuildItem(FUNQY_KNATIVE_FEATURE));

String rootPath = httpConfig.rootPath;
String rootPath = httpBuildTimeConfig.rootPath();
if (rootPath == null) {
rootPath = "/";
} else if (!rootPath.endsWith("/")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import io.quarkus.grpc.runtime.config.GrpcServerConfiguration;
import io.quarkus.grpc.runtime.devmode.GrpcServices;
import io.quarkus.vertx.http.runtime.CertificateConfig;
import io.quarkus.vertx.http.runtime.HttpConfiguration;
import io.quarkus.vertx.http.runtime.VertxHttpConfig;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
import io.smallrye.mutiny.operators.multi.processors.BroadcastProcessor;
Expand All @@ -49,7 +49,7 @@ public class GrpcJsonRPCService {
private Map<String, StreamObserver<Message>> callsInProgress;

@Inject
HttpConfiguration httpConfiguration;
VertxHttpConfig httpConfig;

@Inject
GrpcConfiguration grpcConfiguration;
Expand All @@ -69,18 +69,18 @@ public void init() {
this.port = serverConfig.port;
this.ssl = serverConfig.ssl.certificate.isPresent() || serverConfig.ssl.keyStore.isPresent();
} else {
this.host = httpConfiguration.host;
this.port = httpConfiguration.port;
this.ssl = isTLSConfigured(httpConfiguration.ssl.certificate);
this.host = httpConfig.host();
this.port = httpConfig.port();
this.ssl = isTLSConfigured(httpConfig.ssl().certificate());
}
this.grpcServiceClassInfos = getGrpcServiceClassInfos();
this.callsInProgress = new HashMap<>();
}

private boolean isTLSConfigured(CertificateConfig certificate) {
return certificate.files.isPresent()
|| certificate.keyFiles.isPresent()
|| certificate.keyStoreFile.isPresent();
return certificate.files().isPresent()
|| certificate.keyFiles().isPresent()
|| certificate.keyStoreFile().isPresent();
}

public JsonArray getServices() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.quarkus.devui.spi.page.Page;
import io.quarkus.devui.spi.page.WebComponentPageBuilder;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.runtime.management.ManagementInterfaceBuildTimeConfig;
import io.quarkus.vertx.http.runtime.management.ManagementBuildTimeConfig;

/**
* This processor is responsible for the dev ui widget.
Expand All @@ -20,11 +20,11 @@ public class InfoDevUIProcessor {
void create(BuildProducer<CardPageBuildItem> cardPageProducer,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
InfoBuildTimeConfig config,
ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig,
ManagementBuildTimeConfig managementBuildTimeConfig,
LaunchModeBuildItem launchModeBuildItem) {

var path = nonApplicationRootPathBuildItem.resolveManagementPath(config.path(),
managementInterfaceBuildTimeConfig, launchModeBuildItem);
managementBuildTimeConfig, launchModeBuildItem);

WebComponentPageBuilder infoPage = Page.webComponentPageBuilder()
.title("Information")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import io.quarkus.oidc.runtime.TenantConfigBean;
import io.quarkus.security.spi.runtime.BlockingSecurityExecutor;
import io.quarkus.tls.TlsConfigurationRegistry;
import io.quarkus.vertx.http.runtime.HttpConfiguration;
import io.quarkus.vertx.http.runtime.VertxHttpConfig;
import io.smallrye.mutiny.Uni;
import io.vertx.ext.web.RoutingContext;

Expand All @@ -37,10 +37,10 @@ public class DefaultPolicyEnforcerResolver implements PolicyEnforcerResolver {
private final OidcTlsSupport tlsSupport;

DefaultPolicyEnforcerResolver(TenantConfigBean tenantConfigBean, KeycloakPolicyEnforcerConfig config,
HttpConfiguration httpConfiguration, BlockingSecurityExecutor blockingSecurityExecutor,
VertxHttpConfig httpConfig, BlockingSecurityExecutor blockingSecurityExecutor,
Instance<TenantPolicyConfigResolver> configResolver,
InjectableInstance<TlsConfigurationRegistry> tlsConfigRegistryInstance) {
this.readTimeout = httpConfiguration.readTimeout.toMillis();
this.readTimeout = httpConfig.readTimeout().toMillis();

if (tlsConfigRegistryInstance.isResolvable()) {
this.tlsSupport = OidcTlsSupport.of(tlsConfigRegistryInstance.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,31 @@

import io.quarkus.load.shedding.RequestPrioritizer;
import io.quarkus.load.shedding.RequestPriority;
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig;
import io.quarkus.vertx.http.runtime.management.ManagementInterfaceBuildTimeConfig;
import io.quarkus.vertx.http.runtime.VertxHttpBuildTimeConfig;
import io.quarkus.vertx.http.runtime.management.ManagementBuildTimeConfig;
import io.vertx.core.http.HttpServerRequest;

@Singleton
public class ManagementRequestPrioritizer implements RequestPrioritizer<HttpServerRequest> {
private final String managementPath;

@Inject
public ManagementRequestPrioritizer(HttpBuildTimeConfig httpConfig,
ManagementInterfaceBuildTimeConfig managementInterfaceConfig) {
if (managementInterfaceConfig.enabled) {
public ManagementRequestPrioritizer(
VertxHttpBuildTimeConfig buildTimeConfig,
ManagementBuildTimeConfig managementBuildTimeConfig) {
if (managementBuildTimeConfig.enabled()) {
managementPath = null;
return;
}
if (httpConfig.nonApplicationRootPath.startsWith("/")) {
if (httpConfig.nonApplicationRootPath.equals(httpConfig.rootPath)) {
if (buildTimeConfig.nonApplicationRootPath().startsWith("/")) {
if (buildTimeConfig.nonApplicationRootPath().equals(buildTimeConfig.rootPath())) {
managementPath = null;
return;
}
managementPath = httpConfig.nonApplicationRootPath;
managementPath = buildTimeConfig.nonApplicationRootPath();
return;
}
managementPath = httpConfig.rootPath + httpConfig.nonApplicationRootPath;
managementPath = buildTimeConfig.rootPath() + buildTimeConfig.nonApplicationRootPath();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.quarkus.micrometer.runtime.registry.json.JsonMeterRegistry;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.runtime.management.ManagementInterfaceBuildTimeConfig;
import io.quarkus.vertx.http.runtime.management.ManagementBuildTimeConfig;

@BuildSteps(onlyIf = JsonRegistryProcessor.JsonRegistryEnabled.class)
public class JsonRegistryProcessor {
Expand All @@ -41,7 +41,7 @@ public void initializeJsonRegistry(MicrometerConfig config,
BuildProducer<AdditionalBeanBuildItem> additionalBeans,
BuildProducer<RegistryBuildItem> registries,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig,
ManagementBuildTimeConfig managementBuildTimeConfig,
LaunchModeBuildItem launchModeBuildItem,
JsonRecorder recorder) {
additionalBeans.produce(AdditionalBeanBuildItem.builder()
Expand All @@ -58,7 +58,7 @@ public void initializeJsonRegistry(MicrometerConfig config,
.build());

var path = nonApplicationRootPathBuildItem.resolveManagementPath(config.export.json.path,
managementInterfaceBuildTimeConfig, launchModeBuildItem);
managementBuildTimeConfig, launchModeBuildItem);
log.debug("Initialized a JSON meter registry on path=" + path);

registries.produce(new RegistryBuildItem("JSON", path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.quarkus.micrometer.runtime.export.exemplars.OpentelemetryExemplarSamplerProvider;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.runtime.management.ManagementInterfaceBuildTimeConfig;
import io.quarkus.vertx.http.runtime.management.ManagementBuildTimeConfig;

/**
* Add support for the Prometheus Meter Registry. Note that the registry may not
Expand Down Expand Up @@ -96,7 +96,7 @@ void createPrometheusRoute(BuildProducer<RouteBuildItem> routes,
BuildProducer<RegistryBuildItem> registries,
MicrometerConfig mConfig,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig,
ManagementBuildTimeConfig managementBuildTimeConfig,
LaunchModeBuildItem launchModeBuildItem,
PrometheusRecorder recorder) {

Expand Down Expand Up @@ -134,7 +134,7 @@ void createPrometheusRoute(BuildProducer<RouteBuildItem> routes,
.build());

var path = nonApplicationRootPathBuildItem.resolveManagementPath(pConfig.path,
managementInterfaceBuildTimeConfig, launchModeBuildItem);
managementBuildTimeConfig, launchModeBuildItem);
registries.produce(new RegistryBuildItem("Prometheus", path));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
import io.quarkus.vertx.http.deployment.FilterBuildItem;
import io.quarkus.vertx.http.deployment.HttpAuthMechanismAnnotationBuildItem;
import io.quarkus.vertx.http.deployment.SecurityInformationBuildItem;
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig;
import io.quarkus.vertx.http.runtime.VertxHttpBuildTimeConfig;
import io.smallrye.jwt.auth.cdi.ClaimValueProducer;
import io.smallrye.jwt.auth.cdi.CommonJwtProducer;
import io.smallrye.jwt.auth.cdi.JsonValueProducer;
Expand Down Expand Up @@ -345,11 +345,11 @@ SyntheticBeanBuildItem setup(OidcConfig config, OidcRecorder recorder, SecurityC
@BuildStep
@Record(ExecutionTime.STATIC_INIT)
public void registerTenantResolverInterceptor(Capabilities capabilities, OidcRecorder recorder,
HttpBuildTimeConfig buildTimeConfig,
VertxHttpBuildTimeConfig httpBuildTimeConfig,
CombinedIndexBuildItem combinedIndexBuildItem,
BuildProducer<EagerSecurityInterceptorBindingBuildItem> bindingProducer,
BuildProducer<SystemPropertyBuildItem> systemPropertyProducer) {
if (!buildTimeConfig.auth.proactive
if (!httpBuildTimeConfig.auth().proactive()
&& (capabilities.isPresent(Capability.RESTEASY_REACTIVE) || capabilities.isPresent(Capability.RESTEASY))) {
boolean foundTenantResolver = combinedIndexBuildItem
.getIndex()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.runtime.HttpConfiguration;
import io.quarkus.vertx.http.runtime.VertxHttpConfig;
import io.smallrye.config.ConfigValue;

public abstract class AbstractDevUIProcessor {
Expand All @@ -46,7 +46,7 @@ protected static CardPageBuildItem createProviderWebComponent(OidcDevUiRecorder
Map<String, String> keycloakUsers,
List<String> keycloakRealms,
boolean alwaysLogoutUserInDevUiOnReload,
HttpConfiguration httpConfiguration, boolean discoverMetadata, String authServerUrl) {
VertxHttpConfig httpConfig, boolean discoverMetadata, String authServerUrl) {
final CardPageBuildItem cardPage = new CardPageBuildItem();

// prepare provider component
Expand Down Expand Up @@ -85,7 +85,7 @@ protected static CardPageBuildItem createProviderWebComponent(OidcDevUiRecorder
graphqlIsAvailable, swaggerUiPath, graphqlUiPath, alwaysLogoutUserInDevUiOnReload, discoverMetadata,
authServerUrl);

recorder.createJsonRPCService(beanContainer.getValue(), runtimeProperties, httpConfiguration);
recorder.createJsonRPCService(beanContainer.getValue(), runtimeProperties, httpConfig);

return cardPage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import io.quarkus.runtime.configuration.ConfigUtils;
import io.quarkus.vertx.core.deployment.CoreVertxBuildItem;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.runtime.HttpConfiguration;
import io.quarkus.vertx.http.runtime.VertxHttpConfig;

public class OidcDevUIProcessor extends AbstractDevUIProcessor {

Expand All @@ -49,7 +49,7 @@ public class OidcDevUIProcessor extends AbstractDevUIProcessor {
@Consume(CoreVertxBuildItem.class) // metadata discovery requires Vertx instance
@Consume(RuntimeConfigSetupCompleteBuildItem.class)
void prepareOidcDevConsole(Capabilities capabilities,
HttpConfiguration httpConfiguration,
VertxHttpConfig httpConfig,
BeanContainerBuildItem beanContainer,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
BuildProducer<CardPageBuildItem> cardPageProducer,
Expand Down Expand Up @@ -93,7 +93,7 @@ void prepareOidcDevConsole(Capabilities capabilities,
null,
null,
true,
httpConfiguration, discoverMetadata, authServerUrl);
httpConfig, discoverMetadata, authServerUrl);
cardPageProducer.produce(cardPage);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import io.quarkus.oidc.runtime.devui.OidcDevUiRecorder;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.runtime.HttpConfiguration;
import io.quarkus.vertx.http.runtime.VertxHttpConfig;

public class KeycloakDevUIProcessor extends AbstractDevUIProcessor {

Expand All @@ -38,7 +38,7 @@ public class KeycloakDevUIProcessor extends AbstractDevUIProcessor {
@Consume(RuntimeConfigSetupCompleteBuildItem.class)
void produceProviderComponent(Optional<KeycloakDevServicesConfigBuildItem> configProps,
BuildProducer<KeycloakAdminPageBuildItem> keycloakAdminPageProducer,
HttpConfiguration httpConfiguration,
VertxHttpConfig httpConfig,
OidcDevUiRecorder recorder,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
BeanContainerBuildItem beanContainer,
Expand Down Expand Up @@ -72,7 +72,7 @@ void produceProviderComponent(Optional<KeycloakDevServicesConfigBuildItem> confi
users,
keycloakRealms,
configProps.get().isContainerRestarted(),
httpConfiguration, false, null);
httpConfig, false, null);
// use same card page so that both pages appear on the same card
var keycloakAdminPageItem = new KeycloakAdminPageBuildItem(cardPageBuildItem);
keycloakAdminPageProducer.produce(keycloakAdminPageItem);
Expand Down
Loading

0 comments on commit 45bcf5c

Please sign in to comment.